@riddix/hamh 2.1.0-alpha.761 → 2.1.0-alpha.763

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.
@@ -456,14 +456,14 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
456
456
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
457
457
  `,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(F2(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=z2(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(F2(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(L2(t.key)&&!F2(t.sep,`newline`)){let e=z2(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]}):F2(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&&!F2(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||F2(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=z2(R2(t));B2(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(`
458
458
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
459
- `,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=z2(R2(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=z2(R2(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 H2(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new P2||null,prettyErrors:t}}function Cqe(e,t={}){let{lineCounter:n,prettyErrors:r}=H2(t),i=new V2(n?.addNewLine),a=new y2(t),o=Array.from(a.compose(i.parse(e)));if(r&&n)for(let t of o)t.errors.forEach(t2(e,n)),t.warnings.forEach(t2(e,n));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function U2(e,t={}){let{lineCounter:n,prettyErrors:r}=H2(t),i=new V2(n?.addNewLine),a=new y2(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 $0(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(t2(e,n)),o.warnings.forEach(t2(e,n))),o}function wqe(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=U2(e,n);if(!i)return null;if(i.warnings.forEach(e=>Y1(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 Tqe(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 t1(e)&&!r?e.toString(n):new X0(e,r,n).toString(n)}var Eqe=c({Alias:()=>E1,CST:()=>_qe,Composer:()=>y2,Document:()=>X0,Lexer:()=>N2,LineCounter:()=>P2,Pair:()=>n0,Parser:()=>V2,Scalar:()=>k1,Schema:()=>Y0,YAMLError:()=>Q0,YAMLMap:()=>o0,YAMLParseError:()=>$0,YAMLSeq:()=>c0,YAMLWarning:()=>e2,isAlias:()=>e1,isCollection:()=>o1,isDocument:()=>t1,isMap:()=>n1,isNode:()=>s1,isPair:()=>r1,isScalar:()=>i1,isSeq:()=>a1,parse:()=>wqe,parseAllDocuments:()=>Cqe,parseDocument:()=>U2,stringify:()=>Tqe,visit:()=>f1,visitAsync:()=>m1});function Dqe(e){let t=null;try{t=Eqe.parse(e.doc.toString())}catch{}let n=aq(e,tq.YAML);return{data:t,pointers:n}}var W2=e=>{switch(e){case tq.JSON:return mKe;case tq.JSON5:return gKe;case tq.YAML:return Dqe}};function Oqe(e){return Object.entries(e)}function G2(e,t){if(typeof e==`string`||typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>G2(e,t));if(e instanceof Map){let n=new Map;for(let[r,i]of e){let e=r,a=G2(i,t);n.set(e,a)}return n}if(e instanceof Set){let n=new Set;for(let r of e){let e=G2(r,t);n.add(e)}return n}let n={};function r(e,r,i,a){i===e&&a===r?n[i]=G2(r,t):n[i]=a}for(let[n,i]of Oqe(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 kqe=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},Aqe=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 K2(e){return!(!e||wq(e)||e.name===`UnknownPropertyError`||e.type===`undefined`)}var jqe=class{constructor(e){this.opts=e,this.originalSchema=null,this.schema=null,this.laxSchema=null,this.mode=tq.JSON,this.mode=e.mode??tq.JSON,this.parser=this.opts?.jsonParser??W2(this.mode)}doComplete(e){let t=vq(e.state);if(this.originalSchema!==t&&(this.schema=Y2(t,t)??t,this.laxSchema=Nqe(this.schema)),!this.schema||!this.laxSchema)return[];ZK.log(`xxx`,`trying with original schema`);let n=this.doCompleteForSchema(e,this.schema);return n.options.length===0?(ZK.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=oq(e.state,e.pos),a=e.state.sliceDoc(i.from,e.pos).replace(/^(["'])/,``);if(ZK.log(`xxx`,`node`,i,`prefix`,a,`ctx`,e),!(uq(i,this.mode)||dq(i,this.mode))&&!e.explicit)return ZK.log(`xxx`,`no completions for non-word/primitive`,i),n;let o=cq(e.state.doc,i),s=cq(e.state.doc,i,!1);if(i&&(uq(i,this.mode)||dq(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;ZK.log(`xxx`,`overwriteStart after`,a,`ctx.pos`,e.pos,`word`,t,`currentWord`,o,`=>`,r[a-1],`..`,r[a],`..`,r),n.from=i.name===QK.INVALID?t?.from??e.pos:a,n.to=e.pos}let c=new Aqe,l=!0,u=gq(i,QK.PROPERTY_NAME,this.mode);if(u&&(ZK.log(`xxx`,`closestPropertyNameNode`,u,`node`,i),i=u),dq(i,this.mode)){ZK.log(`xxx`,`isPropertyNameNode`,i);let e=i.parent;if(e){let t=mq(e,this.mode);l=!t||t.name===QK.INVALID&&t.from-t.to===0||(t.parent?fq(t.parent).length<=1:!1),ZK.log(`xxx`,`addValue`,l,mq(e,this.mode),i),i=gq(e,QK.OBJECT,this.mode)??null}}if(ZK.log(`xxx`,i,o,e,`node at pos`,oq(e.state,e.pos)),i&&[QK.OBJECT,QK.JSON_TEXT].includes(nq(i.name,this.mode))&&(dq(oq(e.state,e.pos),this.mode)||u)){if(i.from===e.pos)return ZK.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);ZK.log(`xxx`,`getValueCompletions res`,n)}return n.options=Array.from(c.completions.values()).filter(e=>sq(e.label).startsWith(a)),ZK.log(`xxx`,`result`,n,`prefix`,a,`collector.completions`,c.completions,`reservedKeys`,c.reservedKeys),n}applySnippetCompletion(e){return NLe(typeof e.apply==`string`?e.apply:e.label,e)}getPropertyCompletions(e,t,n,r,i,a){let o=hRe(n,QK.PROPERTY,this.mode);ZK.log(`xxx`,`getPropertyCompletions`,n,t,o),o.forEach(e=>{let n=cq(t.state.doc,pq(e,QK.PROPERTY_NAME,this.mode));r.reserve(sq(n))});let s=this.getSchemas(e,t);ZK.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:()=>EY(`div`,{inner:G$(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&&=Y2(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 tq.JSON5:o=`{#{}}`;break;case tq.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)&&(ZK.log(`xxx`,`value`,o,`nValueProposals`,s,i),o=`#{}`),a+o}getInsertTextForPropertyName(e,t){switch(this.mode){case tq.JSON5:case tq.YAML:return t.startsWith(`"`)?`"${e}"`:t.startsWith(`'`)?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t=`#`){switch(this.mode){case tq.JSON5:return`'${t}{${e}}'`;case tq.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=BH(t.state).resolveInner(t.pos,-1),a=null,o;if(ZK.log(`xxx`,`getValueCompletions`,i,t),i&&uq(i,this.mode)&&(a=i,i=i.parent),!i){this.addSchemaValueCompletions(e,n,r);return}if(nq(i.name,this.mode)===QK.PROPERTY){let e=pq(i,QK.PROPERTY_NAME,this.mode);e&&(o=cq(t.state.doc,e),i=i.parent)}if(ZK.log(`xxx`,`node`,i,`parentKey`,o),i&&(o!==void 0||nq(i.name,this.mode)===QK.ARRAY)){let s=this.getSchemas(e,t);for(let e of s){if(typeof e!=`object`)return;if(nq(i.name,this.mode)===QK.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=hq(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?cq(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 TY(e),i=iq(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=q2(e,n,i);if(t!=null)return[t]}let a=i?.replace(/\/[^/]*$/,``);a===``&&(a=void 0);let o=q2(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),ZK.log(`xxxx`,`draft.getSchema`,l,`data`,n,`pointer`,i,`pointerPointsToKnownProperty`,c),wq(l)&&(l=l.data?.schema),!K2(l)&&o?[o]:(K2(l)||(l=r.getSchema({pointer:a}),i=a),ZK.log(`xxx`,`pointer..`,JSON.stringify(i)),!K2(l)&&(!i||i===`/`)&&(l=Y2(e,e)??e),ZK.log(`xxx`,`subSchema..`,l),l?Array.isArray(l.allOf)?[l,...l.allOf.map(t=>Y2(t,e))]:Array.isArray(l.oneOf)?[l,...l.oneOf.map(t=>Y2(t,e))]:Array.isArray(l.anyOf)?[l,...l.anyOf.map(t=>Y2(t,e))]:[l]:[])}getAppliedValue(e){let t=sq(JSON.stringify(e));switch(this.mode){case tq.JSON5:return{label:t,apply:pRe(JSON.stringify(e))};case tq.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 Mqe(e={}){let t=new jqe(e);return function(e){return t.doComplete(e)}}function Nqe(e){return G2(e,(e,t)=>e===`additionalProperties`&&t===!1||e===`required`&&Array.isArray(t)||e===`unevaluatedProperties`&&t===!1||e===`unevaluatedItems`&&t===!1?[]:[e,t])}function q2(e,t,n){let r=new TY(e),i=r.getSchema({pointer:n,data:t??void 0});if(!K2(i))return;let a=J2(r,i),o={};for(let e of a){let i=Fqe(n,e),a=r.getSchema({pointer:i,data:t??void 0});K2(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=kqe(s,[`allOf`,`anyOf`,`oneOf`]);return Object.assign(Object.assign({},d),{properties:o})}function J2(e,t){if(t=Y2(t,e.rootSchema),typeof t!=`object`||!t)return[];let n=[];function r(t){let r=J2(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 Y2(e,t){if(typeof e==`object`&&e.$ref){let n=Pqe(t,e.$ref);if(typeof n==`object`){let t=Object.assign(Object.assign({},e),n);return Reflect.deleteProperty(t,`$ref`),t}}return e}function Pqe(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 Fqe(e,t){return e===void 0?`/${t}`:`${e}/${t}`}var X2=(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(` `)},Iqe=e=>e?.data?.pointer&&e?.data?.pointer!==`#`?e.data.pointer.slice(1):e?.data?.property?`/${e.data.property}`:``,Lqe=e=>e.startState.field(_q)!==e.state.field(_q);function Rqe(e){let t=new Bqe(e);return e=>t.doValidation(e)}var zqe=[`NoAdditionalPropertiesError`,`RequiredPropertyError`,`InvalidPropertyNameError`,`ForbiddenPropertyError`,`UndefinedValueError`],Bqe=class{constructor(e){this.options=e,this.schema=null,this.mode=tq.JSON,this.rewriteError=e=>{let t=e?.data?.errors;return e.code===`one-of-error`&&t?.length?`Expected one of ${X2(t,e=>e.data.expected)}`:e.code===`type-error`?`Expected \`${e?.data?.expected&&Array.isArray(e?.data?.expected)?X2(e?.data?.expected):e?.data?.expected}\` but received \`${e?.data?.received}\``:e.message.replaceAll("in `#` ",``).replaceAll("at `#`",``).replaceAll(`/`,`.`).replaceAll(`#.`,``)},this.mode=this.options?.mode??tq.JSON,this.parser=this.options?.jsonParser??W2(this.mode)}get schemaTitle(){return this.schema?.getSchema()?.title??`json-schema`}doValidation(e){let t=vq(e.state);if(!t||(this.schema=new xY(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 ZK.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=EY(`div`,{});return e.innerHTML=G$(n),e}})},i=Iqe(t),a=n.pointers.get(i);if(t.name===`MaxPropertiesError`||t.name===`MinPropertiesError`||i===``)r();else if(a){let n=zqe.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=EY(`div`,{});return e.innerHTML=G$(r),e},severity:`error`,source:this.schemaTitle})}else r();return e},[]):[]}};function Vqe(e){let t=new Uqe(e);return async function(e,n,r){return t.doHover(e,n,r)}}function Hqe(e){if(e.type)return e.$ref?`${e.$ref} (${e.type})`:e.type;if(e.$ref)return`${e.$ref}`}function Z2(e,t,n){return`${t}: ${X2(e[t].map(e=>{try{let{data:t}=n.resolveRef({data:e,pointer:e.$ref});return Hqe(t||e)}catch{return e.type}}))}`}var Uqe=class{constructor(e){this.opts=e,this.schema=null,this.mode=tq.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=this.opts?.mode??tq.JSON}getDataForCursor(e,t,n){let r=vq(e.state);if(!r)return null;this.schema=new xY(r);let i=iq(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 wq(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?EY(`div`,{class:`cm6-json-schema-hover`},[EY(`div`,{class:`cm6-json-schema-hover--description`,inner:G$(t,!1)}),EY(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[EY(`div`,{class:`cm6-json-schema-hover--code`,inner:G$(n,!1)})])]):EY(`div`,{class:`cm6-json-schema-hover`},[EY(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[EY(`code`,{class:`cm6-json-schema-hover--code`,inner:G$(n,!1)})])])}getHoverTexts(e,t){let n=``,r=null,{schema:i}=e;return i.oneOf&&(n=Z2(i,`oneOf`,t)),i.anyOf&&(n=Z2(i,`anyOf`,t)),i.allOf&&(n=Z2(i,`allOf`,t)),i.type&&(n=Array.isArray(i.type)?X2(i.type):i.type),i.$ref&&(n=` Reference: ${i.$ref}`),i.enum&&(n=`\`enum\`: ${X2(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(ZK.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 ZK.log(e),null}}},Wqe=e=>(0,G.jsx)(oy,{disablePadding:!0,children:e.validationErrors.map((e,t)=>(0,G.jsx)(ly,{disableGutters:!0,disablePadding:!0,children:(0,G.jsxs)(Yv,{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()))}),Q2=e=>{let t;try{t=JSON.parse(e)}catch{t=void 0}return t};function Gqe({schema:e,customValidate:t}){let n=(0,C.useMemo)(()=>new xOe.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 Kqe=e=>{let t=qqe(),[n,r]=(0,C.useState)(()=>JSON.stringify(e.value,null,2)),i=Gqe(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=Q2(e),n=i(t);s(t,n.length===0),r(e),o(n)},[i,s]),l=()=>{let e=Q2(n);e&&r(JSON.stringify(e,null,2))};return(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsxs)(Z,{position:`relative`,children:[(0,G.jsx)(YK,{value:n,onChange:e=>c(e),extensions:[VPe(),WU(zPe(),{delay:100}),WU(Rqe(),{delay:100,needsRefresh:Lqe}),MU.data.of({autocomplete:Mqe({mode:`json4`})}),gH(Vqe()),vRe(e.schema)],theme:t,height:`400px`}),(0,G.jsx)(xv,{sx:{position:`absolute`,right:`0`,bottom:`0`},onClick:()=>l(),children:`Prettify`})]}),a.length>0&&(0,G.jsx)(Wh,{severity:`error`,variant:`outlined`,children:(0,G.jsx)(Wqe,{validationErrors:a})})]})};function qqe(){return wm().palette.mode===`dark`?lFe:aFe}var Jqe=[{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`}],Yqe=({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&&TE(e).then(t=>{a(t),t&&s(`${EE(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 Ege(e,i),a(!0),s(`${EE(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 Dge(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)(Yv,{spacing:2,children:[(0,G.jsxs)(Iv,{fullWidth:!0,size:`small`,children:[(0,G.jsx)(Ux,{id:`icon-select-label`,children:`Bridge Icon`}),(0,G.jsx)(wS,{labelId:`icon-select-label`,value:t??``,label:`Bridge Icon`,onChange:e=>m(e.target.value),disabled:i,children:Jqe.map(e=>(0,G.jsx)(TS,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(DS,{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)(Yv,{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)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(Bhe,{}),onClick:()=>r.current?.click(),disabled:c,children:c?`Uploading...`:`Upload Image`}),i&&(0,G.jsx)(xv,{variant:`outlined`,size:`small`,color:`error`,startIcon:(0,G.jsx)(RS,{}),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.`})]})},$2={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`,weather:`Sensor`},e4=e=>{try{return JSON.parse(e)}catch{return}};function Xqe({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=e4(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??e4(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 (standalone device node) 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=>!$2[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)(xv,{variant:`outlined`,startIcon:t?(0,G.jsx)(zh,{size:16}):(0,G.jsx)(sge,{}),onClick:d,disabled:t,size:`small`,children:t?`Loading...`:`Preview Matching Entities`}),a&&(0,G.jsx)(Wh,{severity:`error`,sx:{mt:1},children:a}),(0,G.jsx)(iy,{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)(Nv,{label:`Showing first 100`,size:`small`,color:`warning`,variant:`outlined`})]}),p.length>0&&(0,G.jsx)(Yv,{spacing:.5,sx:{mb:1.5},children:p.map(e=>(0,G.jsx)(Wh,{severity:`warning`,variant:`outlined`,icon:e.includes(`vacuum`)?(0,G.jsx)(_v,{fontSize:`small`}):(0,G.jsx)(kb,{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)(Nv,{label:`${e}: ${t}${$2[e]?` → ${$2[e]}`:``}`,size:`small`,variant:`outlined`,color:$2[e]?`default`:`warning`},e))}),(0,G.jsx)(oy,{dense:!0,sx:{maxHeight:200,overflow:`auto`,bgcolor:`background.paper`,borderRadius:1,border:1,borderColor:`divider`},children:r.entities.map(e=>(0,G.jsx)(ly,{divider:!0,children:(0,G.jsx)(py,{primary:e.friendly_name||e.entity_id,secondary:`${e.entity_id}${$2[e.domain]?` → ${$2[e.domain]}`:``}`,primaryTypographyProps:{variant:`body2`},secondaryTypographyProps:{variant:`caption`,fontFamily:`monospace`}})},e.entity_id))}),(0,G.jsx)(xv,{size:`small`,onClick:()=>c(!1),sx:{mt:1},children:`Hide Preview`})]})})]})}var Zqe=iF().ObjectFieldTemplate;function Qqe(e){return(e.fieldPathId?.$id??``)===`root_filter`?(0,G.jsx)($qe,{...e}):(0,G.jsx)(Zqe,{...e})}function $qe(e){let t=(e.formData?.include?.length??0)+(e.formData?.exclude?.length??0),[n,r]=(0,C.useState)(t>0);return(0,G.jsxs)(aC,{expanded:n,onChange:(e,t)=>r(t),variant:`outlined`,disableGutters:!0,sx:{borderRadius:2,"&::before":{display:`none`},overflow:`hidden`},children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),sx:{px:2,"& .MuiAccordionSummary-content":{alignItems:`center`,gap:1.5}},children:[(0,G.jsx)(wb,{fontSize:`small`,color:`action`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:600,children:`Entity Filters`}),(0,G.jsx)(Bx,{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)(oC,{sx:{px:2,pb:2},children:e.properties.map(e=>(0,G.jsx)(`div`,{children:e.content},e.name))})]})}function eJe(e){let t=(0,C.useRef)(e),n=t.current;return t.current=e,n}function t4(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=eJe(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)(Nv,{label:t.length,size:`small`,color:`default`,sx:{height:22,fontSize:`0.75rem`}}),n&&(0,G.jsx)(xv,{size:`small`,startIcon:(0,G.jsx)(yb,{}),onClick:r,children:`Add`})]})]}),t.length>3&&(0,G.jsx)(OS,{size:`small`,fullWidth:!0,placeholder:`Search rules...`,value:l,onChange:e=>u(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(tF,{position:`start`,children:(0,G.jsx)(gE,{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)(Yv,{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)(Ahe,{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)(Nv,{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)(iy,{in:a,children:(0,G.jsx)(Z,{sx:{px:2,pb:1.5,pt:.5},children:t[e]})})]},e)})})]})}var tJe=new Set([``,`pattern`,`regex`]);function nJe(e){let{schema:t,formData:n,onChange:r,disabled:i,readonly:a,fieldPathId:o}=e,s=n??{},c=s.type??``,l=s.value??``,u=i||a,d=t.properties??{},f=(d.type?.oneOf??[]).filter(e=>typeof e.const==`string`),p=d.value?.title??`Value`,m=f.find(e=>e.const===c),h=(0,C.useCallback)(e=>r({...s,type:e},o.path),[s,r,o]),g=(0,C.useCallback)(e=>r({...s,value:e},o.path),[s,r,o]),_=tJe.has(c)&&!u;return(0,G.jsxs)(Yv,{spacing:2,sx:{pt:1},children:[(0,G.jsxs)(Iv,{fullWidth:!0,size:`small`,disabled:u,children:[(0,G.jsx)(Ux,{id:`${o.path}-type`,children:`Type`}),(0,G.jsx)(wS,{labelId:`${o.path}-type`,label:`Type`,value:c,onChange:e=>h(e.target.value),children:f.map(e=>(0,G.jsx)(TS,{value:e.const,children:e.title??e.const},e.const))})]}),m?.description&&(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:m.description}),_?(0,G.jsx)(ZS,{value:l,onChange:g,label:p,placeholder:`sensor.living_room_*`,helperText:`Search or type an entity ID. Wildcards and regex still work.`,margin:`none`}):(0,G.jsx)(OS,{fullWidth:!0,size:`small`,label:p,value:l,disabled:u,onChange:e=>g(e.target.value),helperText:d.value?.description})]})}function rJe(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)(Hv,{container:!0,spacing:2,children:Object.entries(s).map(([e,t])=>{let r=n[e]??t.default??!1;return(0,G.jsx)(Hv,{size:{xs:12,sm:6,lg:4},children:(0,G.jsx)(Sv,{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)(wv,{onClick:()=>{!i&&!a&&c(e,!r)},disabled:i||a,sx:{height:`100%`},children:(0,G.jsxs)(Tv,{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)(Nv,{label:`Active`,size:`small`,color:`primary`,variant:`outlined`,sx:{mt:.5,height:20,fontSize:`0.7rem`}})]}),(0,G.jsx)(qS,{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 n4=e=>{let{t}=Ts(),[n,r]=(0,C.useState)(`FIELDS_EDITOR`),i=()=>{r(n===`FIELDS_EDITOR`?`JSON_EDITOR`:`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. The node carries up to 10 devices; the first entity is the primary and drives the node name and type. More than one device is experimental.`}),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)(Wh,{severity:`warning`,variant:`outlined`,children:[`Please consult`,` `,(0,G.jsx)(Qv,{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)(Wh,{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)(Wh,{severity:e.severity,variant:`outlined`,children:e.message},e.message)),(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsx)(Z,{display:`flex`,justifyContent:`flex-end`,children:(0,G.jsx)(xv,{onClick:()=>i(),title:t(n===`FIELDS_EDITOR`?`bridge.jsonEditor`:`bridge.formEditor`),children:n===`FIELDS_EDITOR`?(0,G.jsx)(fge,{}):(0,G.jsx)(ege,{})})}),n===`FIELDS_EDITOR`&&(0,G.jsx)(nAe,{value:a??{},onChange:u,schema:mv,uiSchema:{icon:{"ui:widget":`hidden`},featureFlags:{"ui:field":`featureFlags`},filter:{include:{"ui:options":{ArrayFieldTemplate:t4},items:{"ui:field":`entityFilterRule`}},exclude:{"ui:options":{ArrayFieldTemplate:t4},items:{"ui:field":`entityFilterRule`}}}},customValidate:l,templates:{ObjectFieldTemplate:Qqe},fields:{featureFlags:rJe,entityFilterRule:nJe}}),n===`JSON_EDITOR`&&(0,G.jsx)(Kqe,{value:a??{},onChange:u,schema:mv,customValidate:l}),a?.filter&&(0,G.jsx)(Xqe,{filter:a.filter}),(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`subtitle1`,gutterBottom:!0,fontWeight:600,children:t(`bridge.iconLabel`)}),(0,G.jsx)(Yqe,{bridgeId:e.bridgeId,selectedIcon:a?.icon,onIconChange:d})]})}),(0,G.jsxs)(Hv,{container:!0,children:[(0,G.jsx)(Hv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(xv,{fullWidth:!0,variant:`outlined`,color:`error`,onClick:e.onCancel,children:t(`common.cancel`)})}),(0,G.jsx)(Hv,{size:{xs:0,sm:4,md:6},sx:{display:{xs:`none`,sm:`block`}}}),(0,G.jsx)(Hv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(xv,{fullWidth:!0,variant:`outlined`,disabled:!s,onClick:async()=>{s&&await e.onSave(a)},children:t(`common.save`)})})]})]})]})},iJe={name:``,featureFlags:{},filter:{include:[],exclude:[]}};function aJe(e){let t=5540;for(;e[t];)t++;return t}var oJe=()=>{let{t:e}=Ts(),t=ey(),n=Pr(),[r,i]=(0,C.useState)(),a=!!FT().content?.length,o=IT(),s=(0,C.useCallback)(e=>{i(e?.id)},[]),c=(0,C.useMemo)(()=>{if(!o)return;let e=aJe(o);if(r){let t=sv.find(e=>e.id===r);if(t)return{name:t.name,port:e,filter:{...t.filter},featureFlags:{...t.featureFlags},icon:t.icon}}return{...iJe,port:e}},[o,r]),l=RT(),u=()=>{n(-1)};return!c||!o?e(`common.loading`):(0,G.jsxs)(Yv,{spacing:4,children:[(0,G.jsx)($v,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:e(`common.create`),to:Y9.createBridge}]}),a&&(0,G.jsx)(Wh,{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)(Qv,{href:Y9.faq.multiFabric,target:`_blank`,children:`Learn more.`})]})}),(0,G.jsx)(BE,{selectedTemplate:r,onSelect:s}),(0,G.jsx)(n4,{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`)]})},sJe=()=>{let{t:e}=Ts(),t=ey(),n=Pr(),{bridgeId:r}=Rr(),{content:i,isLoading:a}=LT(r),o=IT(),s=uhe(),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)(Yv,{spacing:4,children:[(0,G.jsx)($v,{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)(n4,{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 cJe(){let e=await fetch(`api/backup/snapshots`);return await z_(e,`Failed to fetch backups`),R_(e)}async function lJe(){let e=await fetch(`api/backup/snapshots/create`,{method:`POST`});return await z_(e,`Failed to create backup`),R_(e)}async function uJe(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 dJe(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 z_(n,`Failed to restore backup`),R_(n)}async function fJe(e){await z_(await fetch(`api/backup/snapshots/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete backup`)}async function pJe(){let e=await fetch(`api/backup/settings`);return await z_(e,`Failed to fetch backup settings`),R_(e)}async function mJe(e){let t=await fetch(`api/backup/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return await z_(t,`Failed to update backup settings`),R_(t)}function hJe(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function r4(){let{t:e}=Ts(),[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([cJe(),pJe()]);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 lJe(),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 uJe(e)}catch(e){i(e instanceof Error?e.message:`Failed to download backup`)}},z=async t=>{n(!0),i(null);try{let n=await dJe(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 fJe(e),P(null),await L()}catch(e){i(e instanceof Error?e.message:`Failed to delete backup`)}},B=async e=>{try{A(await mJe(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)(Sv,{children:[(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,children:[(0,G.jsx)(YT,{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)(Wh,{severity:`error`,sx:{mb:2},onClose:()=>i(null),children:r}),a&&(0,G.jsx)(Wh,{severity:`success`,sx:{mb:2},onClose:()=>o(null),children:a}),(0,G.jsxs)(Hv,{container:!0,spacing:2,children:[(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(YT,{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)(xv,{variant:`contained`,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):(0,G.jsx)(YT,{}),onClick:()=>V(!1),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.configBackup`)})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(_E,{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)(xv,{variant:`contained`,color:`warning`,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):(0,G.jsx)(YT,{}),onClick:()=>V(!0),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.fullBackup`)})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(mE,{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)(xv,{variant:`outlined`,color:`info`,startIcon:(0,G.jsx)(mE,{}),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)(Xb,{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)(YT,{color:`primary`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.storedBackups`)}),T.length>0&&(0,G.jsx)(Nv,{label:T.length,size:`small`,color:`primary`,variant:`outlined`})]}),(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:F?(0,G.jsx)(zh,{size:16,color:`inherit`}):(0,G.jsx)(yb,{}),onClick:R,disabled:F,children:e(`backup.createSnapshot`)})]}),D?(0,G.jsx)(Z,{display:`flex`,justifyContent:`center`,p:2,children:(0,G.jsx)(zh,{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)(oy,{dense:!0,children:T.map(t=>(0,G.jsxs)(ly,{secondaryAction:(0,G.jsxs)(Z,{display:`flex`,gap:.5,children:[(0,G.jsx)(vb,{title:e(`backup.downloadSnapshot`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>ee(t.filename),children:(0,G.jsx)(jT,{fontSize:`small`})})}),(0,G.jsx)(vb,{title:e(`backup.restoreSnapshot`),children:(0,G.jsx)(Vh,{size:`small`,color:`warning`,onClick:()=>M(t.filename),children:(0,G.jsx)(mE,{fontSize:`small`})})}),(0,G.jsx)(vb,{title:e(`common.delete`),children:(0,G.jsx)(Vh,{size:`small`,color:`error`,onClick:()=>P(t.filename),children:(0,G.jsx)(RS,{fontSize:`small`})})})]}),children:[(0,G.jsx)(dy,{sx:{minWidth:36},children:(0,G.jsx)(YT,{fontSize:`small`,color:t.auto?`action`:`primary`})}),(0,G.jsx)(py,{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)(Nv,{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:hJe(t.sizeBytes)})]}),secondary:new Date(t.createdAt).toLocaleString()})]},t.filename))}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:2,children:[(0,G.jsx)(MT,{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)(Vv,{control:(0,G.jsx)(qS,{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)(OS,{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)(Gb,{open:_,onClose:()=>v(!1),maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Jb,{children:e(`backup.restoreTitle`)}),(0,G.jsx)(qb,{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)(Wh,{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)(oy,{dense:!0,children:s.bridges.map(e=>(0,G.jsxs)(ly,{onClick:()=>ie(e.id),sx:{cursor:`pointer`},children:[(0,G.jsx)(dy,{children:(0,G.jsx)(Av,{edge:`start`,checked:l.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,G.jsx)(py,{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)(Vv,{control:(0,G.jsx)(Av,{checked:d,onChange:e=>f(e.target.checked)}),label:e(`backup.overwriteExisting`)}),(0,G.jsx)(Vv,{control:(0,G.jsx)(Av,{checked:p,onChange:e=>m(e.target.checked)}),label:e(`backup.includeMappings`)}),s?.includesIdentity&&(0,G.jsx)(Vv,{control:(0,G.jsx)(Av,{checked:h,onChange:e=>g(e.target.checked)}),label:e(`backup.restoreIdentities`)})]})]})}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>v(!1),children:e(`common.cancel`)}),(0,G.jsx)(xv,{variant:`contained`,onClick:re,disabled:t||l.size===0,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Gb,{open:y,onClose:()=>b(!1),children:[(0,G.jsxs)(Jb,{children:[(0,G.jsx)(pE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.restartRequired`)]}),(0,G.jsxs)(qb,{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)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>b(!1),children:e(`common.later`)}),(0,G.jsx)(xv,{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)(zh,{size:20,color:`inherit`}):(0,G.jsx)(pE,{}),children:e(`backup.restartNow`)})]})]}),(0,G.jsxs)(Gb,{open:j!==null,onClose:()=>M(null),children:[(0,G.jsxs)(Jb,{children:[(0,G.jsx)(mE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmRestore`)]}),(0,G.jsxs)(qb,{children:[(0,G.jsx)(Q,{children:e(`backup.confirmRestoreMessage`,{filename:j})}),(0,G.jsx)(Wh,{severity:`warning`,sx:{mt:2},children:e(`backup.restoreWarning`)})]}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>M(null),children:e(`common.cancel`)}),(0,G.jsx)(xv,{variant:`contained`,color:`warning`,onClick:()=>j&&z(j),disabled:t,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Gb,{open:N!==null,onClose:()=>P(null),children:[(0,G.jsxs)(Jb,{children:[(0,G.jsx)(RS,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmDelete`)]}),(0,G.jsx)(qb,{children:(0,G.jsx)(Q,{children:e(`backup.confirmDeleteMessage`,{filename:N})})}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>P(null),children:e(`common.cancel`)}),(0,G.jsx)(xv,{variant:`contained`,color:`error`,onClick:()=>N&&te(N),children:e(`common.delete`)})]})]})]})}var gJe=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 _Je(e={}){let{t}=Ts(),[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)(zh,{})}):o||!n?(0,G.jsx)(Wh,{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)(gv,{color:`success`}):n.status===`degraded`?(0,G.jsx)(ny,{color:`warning`}):(0,G.jsx)(Ox,{color:`error`}),(0,G.jsx)(Q,{variant:`h5`,children:t(`health.systemHealth`)}),(0,G.jsx)(Nv,{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)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(XT,{}),onClick:_,children:t(`health.exportDiagnostic`)}),(0,G.jsx)(vb,{title:t(`common.refresh`),children:(0,G.jsx)(Vh,{onClick:g,"aria-label":`Refresh health data`,children:(0,G.jsx)(fE,{})})})]})]}),(0,G.jsxs)(Hv,{container:!0,spacing:2,children:[(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.uptime`)}),(0,G.jsx)(Q,{variant:`h6`,children:gJe(n.uptime)})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.homeAssistant`)}),(0,G.jsx)(Nv,{label:n.services.homeAssistant.connected?t(`health.connected`):t(`health.disconnected`),color:n.services.homeAssistant.connected?`success`:`error`,size:`small`})]})})]}),(0,G.jsx)(Xb,{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)(cE,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.bridgeStatus`)}),(0,G.jsx)(Nv,{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)(Fx,{fontSize:`small`,color:`action`}),(0,G.jsxs)(Iv,{size:`small`,sx:{minWidth:120},children:[(0,G.jsx)(Ux,{children:t(`health.sortBy`)}),(0,G.jsxs)(wS,{value:f,label:t(`health.sortBy`),onChange:e=>m(e.target.value),children:[(0,G.jsx)(TS,{value:`name`,children:t(`common.name`)}),(0,G.jsx)(TS,{value:`created`,children:t(`health.created`)})]})]}),(0,G.jsx)(vb,{title:t(p===`asc`?`health.ascending`:`health.descending`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>h(p===`asc`?`desc`:`asc`),"aria-label":`Sort ${p===`asc`?`descending`:`ascending`}`,children:p===`asc`?(0,G.jsx)(KT,{fontSize:`small`}):(0,G.jsx)(GT,{fontSize:`small`})})})]})]}),(0,G.jsx)(Hv,{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)(Hv,{size:{xs:12,sm:6,md:6,lg:4,xl:3},sx:{display:`flex`},children:(0,G.jsx)(Sv,{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)(Tv,{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)(xb,{}),(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)(Nv,{label:e.status.toUpperCase(),color:e.status===`running`?`success`:e.status===`failed`?`error`:`warning`,size:`small`}),e.status===`failed`&&(0,G.jsx)(vb,{title:t(`bridge.restart`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>v(e.id),children:(0,G.jsx)(JT,{})})})]})]}),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)(Nv,{label:`${t(`common.port`)} ${e.port}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Nv,{label:`${e.deviceCount} ${t(`common.devices`)}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Nv,{label:`${e.fabricCount} ${t(`common.fabrics`)}`,size:`small`,variant:`outlined`,color:`default`}),e.failedEntityCount>0&&(0,G.jsx)(Nv,{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)(vb,{title:(0,G.jsxs)(Z,{sx:{fontSize:`0.75rem`},children:[(0,G.jsxs)(`div`,{children:[`Fabric #`,e.fabricIndex]}),(0,G.jsxs)(`div`,{children:[`Vendor: `,Dx(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)(Nv,{icon:(0,G.jsx)(Uce,{fabric:e}),label:e.label||Dx(e.rootVendorId),size:`small`,variant:`outlined`})},e.fabricIndex))})]}),(()=>{let n=(e.entityDiagnostics??[]).filter(e=>e.status===`failed`);return n.length>0?(0,G.jsxs)(Wh,{severity:`error`,sx:{mt:1,flexShrink:0,py:0},children:[(0,G.jsx)(Q,{variant:`caption`,component:`div`,children:t(`health.failedDevicesTitle`,`Devices that failed to start:`)}),n.map(e=>(0,G.jsxs)(Q,{variant:`caption`,component:`div`,color:`text.secondary`,children:[e.entityId,e.reason?`: ${e.reason}`:``,e.failedAt?` (${hx(e.failedAt)})`:``]},e.entityId))]}):null})(),e.controllerWarnings&&e.controllerWarnings.length>0&&(0,G.jsxs)(Wh,{severity:`warning`,sx:{mt:1,flexShrink:0,py:0},children:[(0,G.jsx)(Q,{variant:`caption`,component:`div`,children:t(`health.controllerWarningsTitle`,`Some devices may not show up in a connected controller:`)}),e.controllerWarnings.map(e=>(0,G.jsxs)(Q,{variant:`caption`,component:`div`,color:`text.secondary`,children:[e.entityId,` on `,e.controllerLabel,e.note?` (${e.note})`:``]},`${e.entityId}:${e.deviceTypeId}:${e.controller}`))]})]})})},e.id))}),n.recovery.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(JT,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.autoRecovery`)}),(0,G.jsx)(Nv,{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()}`]}),n.recovery.history&&n.recovery.history.length>0&&(0,G.jsx)(Z,{sx:{mt:1},children:[...n.recovery.history].reverse().map((e,t)=>(0,G.jsxs)(Q,{variant:`caption`,component:`div`,color:`text.secondary`,children:[hx(e.timestamp),`: `,e.bridgeName,` (`,e.outcome,`)`]},`${e.timestamp}:${e.bridgeId}:${t}`))})]}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsx)(r4,{})]})}var i4=e=>e===`pass`?`success`:e===`warn`?`warning`:`error`;function vJe(){let{t:e}=Ts(),[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)(Gm,{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)(xv,{size:`small`,onClick:l,disabled:r,children:r?(0,G.jsx)(zh,{size:16}):e(`health.refresh`)})]}),a&&(0,G.jsx)(Wh,{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)(Nv,{label:`${u} ${e(`health.checksPassed`)}`,color:`success`,size:`small`,variant:`outlined`}),d>0&&(0,G.jsx)(Nv,{label:`${d} ${e(`health.checksWarning`)}`,color:`warning`,size:`small`,variant:`outlined`}),f>0&&(0,G.jsx)(Nv,{label:`${f} ${e(`health.checksFailed`)}`,color:`error`,size:`small`,variant:`outlined`}),(0,G.jsx)(Nv,{label:t.matterConfig.boundInterface?`mDNS: ${t.matterConfig.boundInterface}`:`mDNS: all interfaces`,size:`small`,variant:`outlined`}),(0,G.jsx)(Nv,{label:`IPv4: ${t.matterConfig.ipv4Enabled?`on`:`off`}`,size:`small`,variant:`outlined`})]}),t.checks.filter(e=>e.status!==`pass`).map(e=>(0,G.jsxs)(Wh,{severity:i4(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)(xv,{size:`small`,onClick:()=>c(!s),sx:{mt:.5},children:e(s?`health.hideDetails`:`health.showDetails`)}),(0,G.jsxs)(iy,{in:s,children:[(0,G.jsx)(Q,{variant:`subtitle2`,sx:{mt:1,mb:.5},children:e(`health.allChecks`)}),(0,G.jsxs)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:e(`health.check`)}),(0,G.jsx)(hC,{children:e(`health.statusLabel`)}),(0,G.jsx)(hC,{children:e(`health.message`)})]})}),(0,G.jsx)(mC,{children:t.checks.map(e=>(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:(0,G.jsx)(Q,{variant:`body2`,children:e.name})}),(0,G.jsx)(hC,{children:(0,G.jsx)(Nv,{label:e.status,color:i4(e.status),size:`small`})}),(0,G.jsxs)(hC,{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)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:e(`health.interfaceName`)}),(0,G.jsx)(hC,{children:`IPv4`}),(0,G.jsx)(hC,{children:`IPv6`}),(0,G.jsx)(hC,{children:`MAC`})]})}),(0,G.jsx)(mC,{children:t.interfaces.filter(e=>!e.internal).map(e=>(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:e.name}),(0,G.jsx)(hC,{children:e.ipv4.join(`, `)||`-`}),(0,G.jsx)(hC,{children:(0,G.jsx)(Q,{variant:`body2`,sx:{wordBreak:`break-all`,maxWidth:240},children:e.ipv6.join(`, `)||`-`})}),(0,G.jsx)(hC,{children:e.mac})]},e.name))})]})]})]})]})}var a4=`hamh-translation-overrides`;function o4(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,o4(i,e)):n[e]=String(i??``)}return n}function s4(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 c4(e){try{let t=localStorage.getItem(a4);return t?JSON.parse(t)[e]??{}:{}}catch{return{}}}function l4(e,t){try{let n=localStorage.getItem(a4),r=n?JSON.parse(n):{};Object.keys(t).length===0?delete r[e]:r[e]=t,localStorage.setItem(a4,JSON.stringify(r))}catch{}}var u4=`hamh-custom-languages`;function yJe(){try{let e=localStorage.getItem(u4);return e?JSON.parse(e):[]}catch{return[]}}function d4(e){localStorage.setItem(u4,JSON.stringify(e))}var f4=[{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 bJe(){let{t:e,i18n:t}=Ts(),n=t.language??`en`,r=f4.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)(()=>c4(i)),[u,d]=(0,C.useState)(!1),[f,p]=(0,C.useState)(`all`),[m,h]=(0,C.useState)(yJe),[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)(()=>[...f4,...m],[m]),O=(0,C.useCallback)(e=>m.some(t=>t.code===e),[m]),k=(0,C.useMemo)(()=>o4(Ds),[]),A=(0,C.useMemo)(()=>{let e=t.getResourceBundle(i,`translation`);return e?o4(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(c4(i))},[i]);let R=(0,C.useCallback)(e=>{l(e),l4(i,e);let n=t.getResourceBundle(i,`translation`),r=n?o4(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=s4({...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=s4(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=s4(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(f4.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),d4(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),d4(e),l4(i,{}),a(f4[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=o4(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)(mge,{}),(0,G.jsx)(Q,{variant:`h5`,children:e(`translationEditor.title`)})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsxs)(Iv,{size:`small`,sx:{minWidth:140},children:[(0,G.jsx)(Ux,{children:e(`translationEditor.editLanguage`)}),(0,G.jsx)(wS,{value:i,label:e(`translationEditor.editLanguage`),onChange:e=>a(e.target.value),children:D.map(e=>(0,G.jsxs)(TS,{value:e.code,children:[(0,G.jsx)(py,{primary:e.name}),O(e.code)&&(0,G.jsx)(dy,{sx:{minWidth:`auto`,ml:1},children:(0,G.jsx)(eE,{fontSize:`small`,color:`disabled`})})]},e.code))})]}),(0,G.jsx)(vb,{title:e(`translationEditor.addLanguage`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>_(e=>!e),children:(0,G.jsx)(yb,{fontSize:`small`})})}),O(i)&&(0,G.jsx)(vb,{title:e(`translationEditor.removeLanguage`),children:(0,G.jsx)(Vh,{size:`small`,color:`error`,onClick:re,children:(0,G.jsx)(eE,{fontSize:`small`})})})]})]}),(0,G.jsx)(iy,{in:g,children:(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:2,alignItems:`flex-start`,flexWrap:`wrap`,children:[(0,G.jsx)(OS,{size:`small`,label:e(`translationEditor.newLanguageCode`),value:v,onChange:e=>y(e.target.value),error:!!S,sx:{width:180}}),(0,G.jsx)(OS,{size:`small`,label:e(`translationEditor.newLanguageName`),value:b,onChange:e=>x(e.target.value),sx:{width:220}}),(0,G.jsx)(xv,{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)(Wh,{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)(Jv,{variant:`determinate`,value:L,sx:{height:8,borderRadius:4}})]}),I>0&&(0,G.jsx)(Nv,{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)(OS,{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)(tF,{position:`start`,children:(0,G.jsx)(gE,{fontSize:`small`})})}}}),(0,G.jsx)(Iv,{size:`small`,sx:{minWidth:130},children:(0,G.jsxs)(wS,{value:f,onChange:e=>p(e.target.value),children:[(0,G.jsx)(TS,{value:`all`,children:e(`translationEditor.filterAll`)}),(0,G.jsx)(TS,{value:`missing`,children:e(`translationEditor.filterMissing`)}),(0,G.jsx)(TS,{value:`edited`,children:e(`translationEditor.filterEdited`)})]})})]}),(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:3,flexWrap:`wrap`,children:[(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(CE,{}),onClick:B,children:e(`translationEditor.exportJson`)}),(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(jT,{}),onClick:ie,children:e(`translationEditor.importJson`)}),(0,G.jsx)(vb,{title:u?e(`translationEditor.copied`):``,children:(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(bb,{}),onClick:V,children:e(`translationEditor.copyJson`)})}),I>0&&(0,G.jsx)(xv,{variant:`outlined`,size:`small`,color:`warning`,startIcon:(0,G.jsx)(mE,{}),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)(Xb,{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)(OS,{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)(vb,{title:e(`translationEditor.resetKey`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>z(t.key),children:(0,G.jsx)(mE,{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)(eg,{open:!!T,autoHideDuration:3e3,onClose:()=>E(``),message:T})]})}var p4=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]}`},m4=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`},xJe=()=>{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)(Sv,{children:(0,G.jsx)(Tv,{children:(0,G.jsx)(Q,{children:`Loading system information...`})})});if(!e)return(0,G.jsx)(Sv,{children:(0,G.jsx)(Tv,{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)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Vhe,{}),`System Information`]}),(0,G.jsxs)(Hv,{container:!0,spacing:3,children:[(0,G.jsx)(Hv,{size:{xs:12,md:6},children:(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`Application`}),(0,G.jsxs)(Yv,{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)(Nv,{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)(Nv,{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:m4(e.process.uptime)})]})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`System`}),(0,G.jsxs)(Yv,{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:m4(e.uptime)})]})]})]})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:6},children:(0,G.jsxs)(Yv,{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)(cE,{}),`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:[p4(e.memory.used),` /`,` `,p4(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)(cE,{}),`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: `,p4(e.process.rss)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[`Heap: `,p4(e.process.heapUsed),` /`,` `,p4(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)(dge,{}),`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:[p4(e.storage.used),` /`,` `,p4(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)(Hv,{size:{xs:12},children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(rge,{}),`Network Interfaces`]}),(0,G.jsx)(Yv,{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)(Nv,{label:`${e.address} (${e.family})`,size:`small`,variant:`outlined`})]},`${e.name}-${e.address}`))})]})]})]})})},SJe=200;function CJe(){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>SJe?n.slice(-200):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 h4(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 g4={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`},_4={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 wJe(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 v4=Object.keys(g4);function TJe({sortField:e,sortDirection:t}={}){let{t:n}=Ts(),r=wm(),{events:i,snapshot:a,connected:o,clearEvents:s}=CJe(),[c,l]=(0,C.useState)(new Set(v4)),[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)(Sv,{children:(0,G.jsxs)(Tv,{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)(pge,{}),(0,G.jsx)(Q,{variant:`h6`,children:n(`diagnostics.title`)}),(0,G.jsx)(Nv,{icon:(0,G.jsx)(qhe,{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)(Yv,{direction:`row`,spacing:.5,alignItems:`center`,children:[(0,G.jsx)(vb,{title:n(`diagnostics.filterEvents`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>d(e=>!e),color:u?`primary`:`default`,children:(0,G.jsx)(wb,{})})}),(0,G.jsx)(vb,{title:n(`diagnostics.clearEvents`),children:(0,G.jsx)(Vh,{size:`small`,onClick:s,children:(0,G.jsx)(zhe,{})})})]})]}),(0,G.jsxs)(Yv,{direction:`row`,spacing:.5,flexWrap:`wrap`,sx:{mb:2,gap:.5},children:[v4.map(e=>{let t=h[e]??0;if(t===0&&!u)return null;let r=g4[e];return(0,G.jsx)(Nv,{label:`${n(_4[e])}: ${t}`,size:`small`,sx:{bgcolor:c.has(e)?r:`action.disabledBackground`,color:c.has(e)?h4(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)(Nv,{label:`Total: ${a.system.eventCount}`,size:`small`,variant:`outlined`,sx:{fontSize:`0.7rem`,height:22}})]}),(0,G.jsx)(iy,{in:u,children:(0,G.jsx)(Gm,{variant:`outlined`,sx:{p:1.5,mb:2},children:(0,G.jsx)(Hv,{container:!0,spacing:0,children:v4.map(e=>{let t=g4[e];return(0,G.jsx)(Hv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(Vv,{control:(0,G.jsx)(Av,{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(_4[e])})})},e)})})})}),m.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Hv,{container:!0,spacing:1,sx:{mb:2},children:m.map(e=>(0,G.jsx)(EJe,{bridge:e},e.bridgeId))}),(0,G.jsx)(Xb,{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=g4[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:wJe(e.timestamp)}),(0,G.jsx)(Nv,{label:_4[e.type]?n(_4[e.type]):e.type,size:`small`,sx:{bgcolor:t??`#757575`,color:h4(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 EJe({bridge:e}){let[t,n]=(0,C.useState)(!1);return(0,G.jsx)(Hv,{size:{xs:12,sm:6},children:(0,G.jsxs)(Gm,{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)(Yv,{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)(Nv,{label:e.replace(/^auto/,``).replace(/([A-Z])/g,` $1`).trim(),size:`small`,variant:`outlined`,sx:{fontSize:`0.6rem`,height:18}},e)),(0,G.jsx)(Nv,{label:e.status,size:`small`,color:e.status===`running`?`success`:e.status===`failed`?`error`:`default`,sx:{height:20}}),(0,G.jsx)(eC,{sx:{transform:t?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`,fontSize:18,color:`text.secondary`}})]})]}),(0,G.jsx)(iy,{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)(Nv,{label:e,size:`small`,variant:`outlined`,sx:{fontSize:`0.58rem`,height:16,"& .MuiChip-label":{px:.5}}},e))})]},e.entityId))})})]})})}var DJe=()=>{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)(_Je,{sortField:e,sortDirection:n,onSortFieldChange:t,onSortDirectionChange:r}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(TJe,{sortField:e,sortDirection:n})}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(vJe,{})}),(0,G.jsx)(Z,{sx:{px:2,pb:2},children:(0,G.jsx)(xJe,{})}),(0,G.jsx)(Xb,{}),(0,G.jsx)(bJe,{})]})};async function OJe(){let e=await fetch(`api/matter/labels?_s=${Date.now()}`);return await z_(e,`Failed to fetch labels`),R_(e)}async function kJe(){let e=await fetch(`api/matter/areas?_s=${Date.now()}`);return await z_(e,`Failed to fetch areas`),R_(e)}async function AJe(){let e=await fetch(`api/matter/filter-values?_s=${Date.now()}`);return await z_(e,`Failed to fetch filter values`),R_(e)}var y4=({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)(OS,{size:`small`,fullWidth:!0,placeholder:`Search...`,value:i,onChange:e=>a(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(tF,{position:`start`,children:(0,G.jsx)(gE,{fontSize:`small`})})}}})}),(0,G.jsxs)(Z,{sx:{p:1.5,display:`flex`,flexWrap:`wrap`,gap:.75},children:[o.map(e=>(0,G.jsx)(Nv,{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,`"`]})]})]})},jJe=()=>{let{t:e}=Ts(),[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([OJe(),kJe(),AJe()]);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)(zh,{})}):(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,sx:{mb:3},children:[(0,G.jsx)(wb,{sx:{mr:1,verticalAlign:`middle`}}),e(`labels.title`)]}),(0,G.jsx)(Wh,{severity:`info`,sx:{mb:3},children:e(`labels.info`)}),l&&(0,G.jsx)(Wh,{severity:`error`,sx:{mb:2},children:l}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)(oE,{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)(Sv,{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)(gC,{children:(0,G.jsxs)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.labelId`)}),(0,G.jsx)(hC,{width:48})]})}),(0,G.jsx)(mC,{children:t.map(t=>(0,G.jsxs)(xC,{hover:!0,children:[(0,G.jsxs)(hC,{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)(hC,{children:(0,G.jsx)(`code`,{children:t.label_id})}),(0,G.jsx)(hC,{children:(0,G.jsx)(vb,{title:d===t.label_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>m(t.label_id),children:(0,G.jsx)(bb,{fontSize:`small`})})})})]},t.label_id))})]})})}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)(wT,{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)(Sv,{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)(gC,{children:(0,G.jsxs)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.areaId`)}),(0,G.jsx)(hC,{width:48})]})}),(0,G.jsx)(mC,{children:r.map(t=>(0,G.jsxs)(xC,{hover:!0,children:[(0,G.jsx)(hC,{children:t.name}),(0,G.jsx)(hC,{children:(0,G.jsx)(`code`,{children:t.area_id})}),(0,G.jsx)(hC,{children:(0,G.jsx)(vb,{title:d===t.area_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>m(t.area_id),children:(0,G.jsx)(bb,{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)(aC,{defaultExpanded:!0,children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(_ge,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.domains`),` (`,a.domains.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.domains,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(nE,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.platforms`),` (`,a.platforms.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.platforms,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(ZT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.entityCategories`),` (`,a.entityCategories.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.entityCategories,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(ZT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceClasses`),` (`,a.deviceClasses.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.deviceClasses,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(xb,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceNames`),` (`,a.deviceNames.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.deviceNames,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(xb,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.productNames`),` (`,a.productNames.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.productNames,copiedId:d,onCopy:m,searchable:!0})]})]})]})]})};async function MJe(){let e=await fetch(`api/lock-credentials`);return await z_(e,`Failed to fetch lock credentials`),R_(e)}async function NJe(e,t){let n=await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return await z_(n,`Failed to update lock credential`),R_(n)}async function PJe(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 z_(n,`Failed to toggle credential`),R_(n)}async function FJe(e){await z_(await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete lock credential`)}var IJe=({open:e,onClose:t,onSave:n,initialEntityId:r=``,initialName:i=``,isEdit:a=!1})=>{let{t:o}=Ts(),[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)(Gb,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Jb,{children:o(a?`lockCredentials.editCredential`:`lockCredentials.addCredential`)}),(0,G.jsx)(qb,{children:(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,mt:1},children:[p&&(0,G.jsx)(Wh,{severity:`error`,children:p}),(0,G.jsx)(OS,{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)(OS,{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)(OS,{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)(Kb,{children:[(0,G.jsx)(xv,{onClick:t,disabled:h,children:o(`common.cancel`)}),(0,G.jsx)(xv,{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)(zh,{size:16}):(0,G.jsx)(hE,{}),children:o(`common.save`)})]})]})},LJe=()=>{let{t:e}=Ts(),[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 MJe()).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 NJe(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 FJe(t),await d()}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.deleteFailed`))}},g=async t=>{try{await PJe(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)(CT,{sx:{mr:1,verticalAlign:`middle`}}),e(`lockCredentials.title`)]}),(0,G.jsx)(xv,{variant:`contained`,startIcon:(0,G.jsx)(yb,{}),onClick:v,children:e(`lockCredentials.addCredential`)})]}),(0,G.jsx)(Wh,{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)(Wh,{severity:`error`,sx:{mb:2},children:a}),r?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(zh,{})}):t.length===0?(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{sx:{textAlign:`center`,py:4},children:[(0,G.jsx)(CT,{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)(xv,{variant:`outlined`,startIcon:(0,G.jsx)(yb,{}),onClick:v,children:`Add Your First Credential`})]})}):(0,G.jsx)(Sv,{children:(0,G.jsx)(oy,{children:t.map((n,r)=>(0,G.jsxs)(ly,{divider:r<t.length-1,onClick:()=>_(n),sx:{cursor:`pointer`,"&:hover":{bgcolor:`action.hover`}},children:[(0,G.jsx)(dy,{children:(0,G.jsx)(CT,{color:n.enabled?`primary`:`disabled`})}),(0,G.jsx)(py,{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)(cy,{children:[(0,G.jsx)(vb,{title:n.enabled?e(`lockCredentials.disable`):e(`lockCredentials.enable`),children:(0,G.jsx)(qS,{edge:`end`,checked:n.enabled,onChange:e=>{e.stopPropagation(),g(n)}})}),(0,G.jsx)(vb,{title:e(`common.delete`),children:(0,G.jsx)(Vh,{edge:`end`,onClick:e=>{e.stopPropagation(),m(n.entityId)},sx:{ml:1},children:(0,G.jsx)(RS,{})})})]})]},n.entityId))})}),(0,G.jsx)(IJe,{open:s,onClose:()=>c(!1),onSave:f,initialEntityId:l?.entityId,initialName:l?.name,isEdit:!!l}),(0,G.jsx)(VT,{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)})]})},RJe=()=>{let e=Pr(),{t}=Ts();return(0,G.jsxs)(Z,{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,minHeight:`60vh`,gap:2,p:4,children:[(0,G.jsx)(lge,{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)(xv,{variant:`contained`,startIcon:(0,G.jsx)(iE,{}),onClick:()=>e(Y9.dashboard),children:t(`notFound.backToDashboard`)})]})};function b4(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=b4(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var zJe={value:()=>{}};function x4(){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 S4(n)}function S4(e){this._=e}function BJe(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}})}S4.prototype=x4.prototype={constructor:S4,on:function(e,t){var n=this._,r=BJe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=VJe(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]=C4(n[i],e.name,t);else if(t==null)for(i in n)n[i]=C4(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 S4(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 VJe(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function C4(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=zJe,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var w4={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 T4(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),w4.hasOwnProperty(t)?{space:w4[t],local:e}:e}function HJe(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 UJe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function E4(e){var t=T4(e);return(t.local?UJe:HJe)(t)}function WJe(){}function D4(e){return e==null?WJe:function(){return this.querySelector(e)}}function GJe(e){typeof e!=`function`&&(e=D4(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 H4(r,this._parents)}function KJe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function qJe(){return[]}function O4(e){return e==null?qJe:function(){return this.querySelectorAll(e)}}function JJe(e){return function(){return KJe(e.apply(this,arguments))}}function YJe(e){e=typeof e==`function`?JJe(e):O4(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 H4(r,i)}function k4(e){return function(){return this.matches(e)}}function A4(e){return function(t){return t.matches(e)}}var XJe=Array.prototype.find;function ZJe(e){return function(){return XJe.call(this.children,e)}}function QJe(){return this.firstElementChild}function $Je(e){return this.select(e==null?QJe:ZJe(typeof e==`function`?e:A4(e)))}var eYe=Array.prototype.filter;function tYe(){return Array.from(this.children)}function nYe(e){return function(){return eYe.call(this.children,e)}}function rYe(e){return this.selectAll(e==null?tYe:nYe(typeof e==`function`?e:A4(e)))}function iYe(e){typeof e!=`function`&&(e=k4(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 H4(r,this._parents)}function j4(e){return Array(e.length)}function aYe(){return new H4(this._enter||this._groups.map(j4),this._parents)}function M4(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}M4.prototype={constructor:M4,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 oYe(e){return function(){return e}}function sYe(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 M4(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function cYe(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 M4(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function lYe(e){return e.__data__}function uYe(e,t){if(!arguments.length)return Array.from(this,lYe);var n=t?cYe:sYe,r=this._parents,i=this._groups;typeof e!=`function`&&(e=oYe(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=dYe(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 H4(o,r),o._enter=s,o._exit=c,o}function dYe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function fYe(){return new H4(this._exit||this._groups.map(j4),this._parents)}function pYe(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 mYe(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 H4(s,this._parents)}function hYe(){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 gYe(e){e||=_Ye;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 H4(i,this._parents).order()}function _Ye(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function vYe(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yYe(){return Array.from(this)}function bYe(){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 xYe(){let e=0;for(let t of this)++e;return e}function SYe(){return!this.node()}function CYe(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 wYe(e){return function(){this.removeAttribute(e)}}function TYe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function EYe(e,t){return function(){this.setAttribute(e,t)}}function DYe(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function OYe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function kYe(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 AYe(e,t){var n=T4(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?TYe:wYe:typeof t==`function`?n.local?kYe:OYe:n.local?DYe:EYe)(n,t))}function N4(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function jYe(e){return function(){this.style.removeProperty(e)}}function MYe(e,t,n){return function(){this.style.setProperty(e,t,n)}}function NYe(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function PYe(e,t,n){return arguments.length>1?this.each((t==null?jYe:typeof t==`function`?NYe:MYe)(e,t,n??``)):P4(this.node(),e)}function P4(e,t){return e.style.getPropertyValue(t)||N4(e).getComputedStyle(e,null).getPropertyValue(t)}function FYe(e){return function(){delete this[e]}}function IYe(e,t){return function(){this[e]=t}}function LYe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function RYe(e,t){return arguments.length>1?this.each((t==null?FYe:typeof t==`function`?LYe:IYe)(e,t)):this.node()[e]}function F4(e){return e.trim().split(/^|\s+/)}function I4(e){return e.classList||new L4(e)}function L4(e){this._node=e,this._names=F4(e.getAttribute(`class`)||``)}L4.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 R4(e,t){for(var n=I4(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function z4(e,t){for(var n=I4(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function zYe(e){return function(){R4(this,e)}}function BYe(e){return function(){z4(this,e)}}function VYe(e,t){return function(){(t.apply(this,arguments)?R4:z4)(this,e)}}function HYe(e,t){var n=F4(e+``);if(arguments.length<2){for(var r=I4(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?VYe:t?zYe:BYe)(n,t))}function UYe(){this.textContent=``}function WYe(e){return function(){this.textContent=e}}function GYe(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function KYe(e){return arguments.length?this.each(e==null?UYe:(typeof e==`function`?GYe:WYe)(e)):this.node().textContent}function qYe(){this.innerHTML=``}function JYe(e){return function(){this.innerHTML=e}}function YYe(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function XYe(e){return arguments.length?this.each(e==null?qYe:(typeof e==`function`?YYe:JYe)(e)):this.node().innerHTML}function ZYe(){this.nextSibling&&this.parentNode.appendChild(this)}function QYe(){return this.each(ZYe)}function $Ye(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eXe(){return this.each($Ye)}function tXe(e){var t=typeof e==`function`?e:E4(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function nXe(){return null}function rXe(e,t){var n=typeof e==`function`?e:E4(e),r=t==null?nXe:typeof t==`function`?t:D4(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function iXe(){var e=this.parentNode;e&&e.removeChild(this)}function aXe(){return this.each(iXe)}function oXe(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sXe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cXe(e){return this.select(e?sXe:oXe)}function lXe(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function uXe(e){return function(t){e.call(this,t,this.__data__)}}function dXe(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 fXe(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 pXe(e,t,n){return function(){var r=this.__on,i,a=uXe(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 mXe(e,t,n){var r=dXe(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?pXe:fXe,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function B4(e,t,n){var r=N4(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 hXe(e,t){return function(){return B4(this,e,t)}}function gXe(e,t){return function(){return B4(this,e,t.apply(this,arguments))}}function _Xe(e,t){return this.each((typeof t==`function`?gXe:hXe)(e,t))}function*vXe(){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 V4=[null];function H4(e,t){this._groups=e,this._parents=t}function U4(){return new H4([[document.documentElement]],V4)}function yXe(){return this}H4.prototype=U4.prototype={constructor:H4,select:GJe,selectAll:YJe,selectChild:$Je,selectChildren:rYe,filter:iYe,data:uYe,enter:aYe,exit:fYe,join:pYe,merge:mYe,selection:yXe,order:hYe,sort:gYe,call:vYe,nodes:yYe,node:bYe,size:xYe,empty:SYe,each:CYe,attr:AYe,style:PYe,property:RYe,classed:HYe,text:KYe,html:XYe,raise:QYe,lower:eXe,append:tXe,insert:rXe,remove:aXe,clone:cXe,datum:lXe,on:mXe,dispatch:_Xe,[Symbol.iterator]:vXe};function W4(e){return typeof e==`string`?new H4([[document.querySelector(e)]],[document.documentElement]):new H4([[e]],V4)}function bXe(e){let t;for(;t=e.sourceEvent;)e=t;return e}function G4(e,t){if(e=bXe(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 xXe={passive:!1},K4={capture:!0,passive:!1};function q4(e){e.stopImmediatePropagation()}function J4(e){e.preventDefault(),e.stopImmediatePropagation()}function Y4(e){var t=e.document.documentElement,n=W4(e).on(`dragstart.drag`,J4,K4);`onselectstart`in t?n.on(`selectstart.drag`,J4,K4):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function X4(e,t){var n=e.document.documentElement,r=W4(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,J4,K4),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 Z4=e=>()=>e;function Q4(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}})}Q4.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function SXe(e){return!e.ctrlKey&&!e.button}function CXe(){return this.parentNode}function wXe(e,t){return t??{x:e.x,y:e.y}}function TXe(){return navigator.maxTouchPoints||`ontouchstart`in this}function $4(){var e=SXe,t=CXe,n=wXe,r=TXe,i={},a=x4(`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`,_,xXe).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&&(W4(n.view).on(`mousemove.drag`,m,K4).on(`mouseup.drag`,h,K4),Y4(n.view),q4(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(J4(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){W4(e.view).on(`mousemove.drag mouseup.drag`,null),X4(e.view,l),J4(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]))&&(q4(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])&&(J4(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])&&(q4(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=G4(l||r,t),p,m,h;if((h=n.call(e,new Q4(`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=G4(l||a,t),_=o;break}u.call(r,e,new Q4(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:Z4(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:Z4(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:Z4(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:Z4(!!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 e3(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function t3(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function n3(){}var r3=.7,i3=1/r3,a3=`\\s*([+-]?\\d+)\\s*`,o3=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,s3=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,EXe=/^#([0-9a-f]{3,8})$/,DXe=RegExp(`^rgb\\(${a3},${a3},${a3}\\)$`),OXe=RegExp(`^rgb\\(${s3},${s3},${s3}\\)$`),kXe=RegExp(`^rgba\\(${a3},${a3},${a3},${o3}\\)$`),AXe=RegExp(`^rgba\\(${s3},${s3},${s3},${o3}\\)$`),jXe=RegExp(`^hsl\\(${o3},${s3},${s3}\\)$`),MXe=RegExp(`^hsla\\(${o3},${s3},${s3},${o3}\\)$`),c3={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};e3(n3,d3,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:l3,formatHex:l3,formatHex8:NXe,formatHsl:PXe,formatRgb:u3,toString:u3});function l3(){return this.rgb().formatHex()}function NXe(){return this.rgb().formatHex8()}function PXe(){return S3(this).formatHsl()}function u3(){return this.rgb().formatRgb()}function d3(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=EXe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?f3(t):n===3?new h3(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?p3(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?p3(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=DXe.exec(e))?new h3(t[1],t[2],t[3],1):(t=OXe.exec(e))?new h3(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=kXe.exec(e))?p3(t[1],t[2],t[3],t[4]):(t=AXe.exec(e))?p3(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jXe.exec(e))?x3(t[1],t[2]/100,t[3]/100,1):(t=MXe.exec(e))?x3(t[1],t[2]/100,t[3]/100,t[4]):c3.hasOwnProperty(e)?f3(c3[e]):e===`transparent`?new h3(NaN,NaN,NaN,0):null}function f3(e){return new h3(e>>16&255,e>>8&255,e&255,1)}function p3(e,t,n,r){return r<=0&&(e=t=n=NaN),new h3(e,t,n,r)}function FXe(e){return e instanceof n3||(e=d3(e)),e?(e=e.rgb(),new h3(e.r,e.g,e.b,e.opacity)):new h3}function m3(e,t,n,r){return arguments.length===1?FXe(e):new h3(e,t,n,r??1)}function h3(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}e3(h3,m3,t3(n3,{brighter(e){return e=e==null?i3:i3**+e,new h3(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?r3:r3**+e,new h3(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new h3(y3(this.r),y3(this.g),y3(this.b),v3(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:g3,formatHex:g3,formatHex8:IXe,formatRgb:_3,toString:_3}));function g3(){return`#${b3(this.r)}${b3(this.g)}${b3(this.b)}`}function IXe(){return`#${b3(this.r)}${b3(this.g)}${b3(this.b)}${b3((isNaN(this.opacity)?1:this.opacity)*255)}`}function _3(){let e=v3(this.opacity);return`${e===1?`rgb(`:`rgba(`}${y3(this.r)}, ${y3(this.g)}, ${y3(this.b)}${e===1?`)`:`, ${e})`}`}function v3(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function y3(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function b3(e){return e=y3(e),(e<16?`0`:``)+e.toString(16)}function x3(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new C3(e,t,n,r)}function S3(e){if(e instanceof C3)return new C3(e.h,e.s,e.l,e.opacity);if(e instanceof n3||(e=d3(e)),!e)return new C3;if(e instanceof C3)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 C3(o,s,c,e.opacity)}function LXe(e,t,n,r){return arguments.length===1?S3(e):new C3(e,t,n,r??1)}function C3(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}e3(C3,LXe,t3(n3,{brighter(e){return e=e==null?i3:i3**+e,new C3(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?r3:r3**+e,new C3(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 h3(E3(e>=240?e-240:e+120,i,r),E3(e,i,r),E3(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new C3(w3(this.h),T3(this.s),T3(this.l),v3(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=v3(this.opacity);return`${e===1?`hsl(`:`hsla(`}${w3(this.h)}, ${T3(this.s)*100}%, ${T3(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function w3(e){return e=(e||0)%360,e<0?e+360:e}function T3(e){return Math.max(0,Math.min(1,e||0))}function E3(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 D3=e=>()=>e;function RXe(e,t){return function(n){return e+n*t}}function zXe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function BXe(e){return(e=+e)==1?O3:function(t,n){return n-t?zXe(t,n,e):D3(isNaN(t)?n:t)}}function O3(e,t){var n=t-e;return n?RXe(e,n):D3(isNaN(e)?t:e)}var k3=(function e(t){var n=BXe(t);function r(e,t){var r=n((e=m3(e)).r,(t=m3(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=O3(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 VXe(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 HXe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function UXe(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]=P3(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 WXe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function A3(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function GXe(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]=P3(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var j3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,M3=new RegExp(j3.source,`g`);function KXe(e){return function(){return e}}function qXe(e){return function(t){return e(t)+``}}function N3(e,t){var n=j3.lastIndex=M3.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=j3.exec(e))&&(i=M3.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:A3(r,i)})),n=M3.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?qXe(c[0].x):KXe(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 P3(e,t){var n=typeof t,r;return t==null||n===`boolean`?D3(t):(n===`number`?A3:n===`string`?(r=d3(t))?(t=r,k3):N3:t instanceof d3?k3:t instanceof Date?WXe:HXe(t)?VXe:Array.isArray(t)?UXe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?GXe:A3)(e,t)}var F3=180/Math.PI,I3={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function L3(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)*F3,skewX:Math.atan(c)*F3,scaleX:o,scaleY:s}}var R3;function JXe(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?I3:L3(t.a,t.b,t.c,t.d,t.e,t.f)}function YXe(e){return e==null||(R3||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),R3.setAttribute(`transform`,e),!(e=R3.transform.baseVal.consolidate()))?I3:(e=e.matrix,L3(e.a,e.b,e.c,e.d,e.e,e.f))}function z3(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:A3(e,i)},{i:c-2,x:A3(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:A3(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:A3(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:A3(e,n)},{i:s-2,x:A3(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 XXe=z3(JXe,`px, `,`px)`,`deg)`),ZXe=z3(YXe,`, `,`)`,`)`),QXe=1e-12;function B3(e){return((e=Math.exp(e))+1/e)/2}function $Xe(e){return((e=Math.exp(e))-1/e)/2}function eZe(e){return((e=Math.exp(2*e))-1)/(e+1)}var V3=(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<QXe)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=B3(y),c=s/(n*g)*(i*eZe(t*r+y)-$Xe(y));return[a+c*d,o+c*f,s*i/B3(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),H3=0,U3=0,W3=0,G3=1e3,K3,q3,J3=0,Y3=0,X3=0,Z3=typeof performance==`object`&&performance.now?performance:Date,Q3=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function $3(){return Y3||=(Q3(tZe),Z3.now()+X3)}function tZe(){Y3=0}function e6(){this._call=this._time=this._next=null}e6.prototype=t6.prototype={constructor:e6,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?$3():+n)+(t==null?0:+t),!this._next&&q3!==this&&(q3?q3._next=this:K3=this,q3=this),this._call=e,this._time=n,r6()},stop:function(){this._call&&(this._call=null,this._time=1/0,r6())}};function t6(e,t,n){var r=new e6;return r.restart(e,t,n),r}function nZe(){$3(),++H3;for(var e=K3,t;e;)(t=Y3-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H3}function n6(){Y3=(J3=Z3.now())+X3,H3=U3=0;try{nZe()}finally{H3=0,iZe(),Y3=0}}function rZe(){var e=Z3.now(),t=e-J3;t>G3&&(X3-=t,J3=e)}function iZe(){for(var e,t=K3,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:K3=n);q3=e,r6(r)}function r6(e){H3||(U3&&=clearTimeout(U3),e-Y3>24?(e<1/0&&(U3=setTimeout(n6,e-Z3.now()-X3)),W3&&=clearInterval(W3)):(W3||=(J3=Z3.now(),setInterval(rZe,G3)),H3=1,Q3(n6)))}function i6(e,t,n){var r=new e6;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var aZe=x4(`start`,`end`,`cancel`,`interrupt`),oZe=[];function a6(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;sZe(e,n,{name:t,index:r,group:i,on:aZe,tween:oZe,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function o6(e,t){var n=c6(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function s6(e,t){var n=c6(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function c6(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function sZe(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=t6(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 i6(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(i6(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 l6(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 cZe(e){return this.each(function(){l6(this,e)})}function lZe(e,t){var n,r;return function(){var i=s6(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 uZe(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=s6(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 dZe(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=c6(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?lZe:uZe)(n,e,t))}function u6(e,t,n){var r=e._id;return e.each(function(){var e=s6(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return c6(e,r).value[t]}}function d6(e,t){var n;return(typeof t==`number`?A3:t instanceof d3?k3:(n=d3(t))?(t=n,k3):N3)(e,t)}function fZe(e){return function(){this.removeAttribute(e)}}function pZe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mZe(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 hZe(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 gZe(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 _Ze(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 vZe(e,t){var n=T4(e),r=n===`transform`?ZXe:d6;return this.attrTween(e,typeof t==`function`?(n.local?_Ze:gZe)(n,r,u6(this,`attr.`+e,t)):t==null?(n.local?pZe:fZe)(n):(n.local?hZe:mZe)(n,r,t))}function yZe(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function bZe(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function xZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&bZe(e,i)),n}return i._value=t,i}function SZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&yZe(e,i)),n}return i._value=t,i}function CZe(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=T4(e);return this.tween(n,(r.local?xZe:SZe)(r,t))}function wZe(e,t){return function(){o6(this,e).delay=+t.apply(this,arguments)}}function TZe(e,t){return t=+t,function(){o6(this,e).delay=t}}function EZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?wZe:TZe)(t,e)):c6(this.node(),t).delay}function DZe(e,t){return function(){s6(this,e).duration=+t.apply(this,arguments)}}function OZe(e,t){return t=+t,function(){s6(this,e).duration=t}}function kZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?DZe:OZe)(t,e)):c6(this.node(),t).duration}function AZe(e,t){if(typeof t!=`function`)throw Error();return function(){s6(this,e).ease=t}}function jZe(e){var t=this._id;return arguments.length?this.each(AZe(t,e)):c6(this.node(),t).ease}function MZe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();s6(this,e).ease=n}}function NZe(e){if(typeof e!=`function`)throw Error();return this.each(MZe(this._id,e))}function PZe(e){typeof e!=`function`&&(e=k4(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 p6(r,this._parents,this._name,this._id)}function FZe(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 p6(o,this._parents,this._name,this._id)}function IZe(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 LZe(e,t,n){var r,i,a=IZe(t)?o6:s6;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function RZe(e,t){var n=this._id;return arguments.length<2?c6(this.node(),n).on.on(e):this.each(LZe(n,e,t))}function zZe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function BZe(){return this.on(`end.remove`,zZe(this._id))}function VZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=D4(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,a6(l[f],t,n,f,l,c6(u,n)));return new p6(a,this._parents,t,n)}function HZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=O4(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=c6(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&a6(p,t,n,h,f,m);a.push(f),o.push(u)}return new p6(a,o,t,n)}var UZe=U4.prototype.constructor;function WZe(){return new UZe(this._groups,this._parents)}function GZe(e,t){var n,r,i;return function(){var a=P4(this,e),o=(this.style.removeProperty(e),P4(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function f6(e){return function(){this.style.removeProperty(e)}}function KZe(e,t,n){var r,i=n+``,a;return function(){var o=P4(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function qZe(e,t,n){var r,i,a;return function(){var o=P4(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),P4(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function JZe(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=s6(this,e),l=c.on,u=c.value[a]==null?s||=f6(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function YZe(e,t,n){var r=(e+=``)==`transform`?XXe:d6;return t==null?this.styleTween(e,GZe(e,r)).on(`end.style.`+e,f6(e)):typeof t==`function`?this.styleTween(e,qZe(e,r,u6(this,`style.`+e,t))).each(JZe(this._id,e)):this.styleTween(e,KZe(e,r,t),n).on(`end.style.`+e,null)}function XZe(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function ZZe(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&XZe(e,a,n)),r}return a._value=t,a}function QZe(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,ZZe(e,t,n??``))}function $Ze(e){return function(){this.textContent=e}}function eQe(e){return function(){var t=e(this);this.textContent=t??``}}function tQe(e){return this.tween(`text`,typeof e==`function`?eQe(u6(this,`text`,e)):$Ze(e==null?``:e+``))}function nQe(e){return function(t){this.textContent=e.call(this,t)}}function rQe(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&nQe(r)),t}return r._value=e,r}function iQe(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,rQe(e))}function aQe(){for(var e=this._name,t=this._id,n=m6(),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=c6(c,t);a6(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new p6(r,this._parents,e,n)}function oQe(){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=s6(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 sQe=0;function p6(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function cQe(e){return U4().transition(e)}function m6(){return++sQe}var h6=U4.prototype;p6.prototype=cQe.prototype={constructor:p6,select:VZe,selectAll:HZe,selectChild:h6.selectChild,selectChildren:h6.selectChildren,filter:PZe,merge:FZe,selection:WZe,transition:aQe,call:h6.call,nodes:h6.nodes,node:h6.node,size:h6.size,empty:h6.empty,each:h6.each,on:RZe,attr:vZe,attrTween:CZe,style:YZe,styleTween:QZe,text:tQe,textTween:iQe,remove:BZe,tween:dZe,delay:EZe,duration:kZe,ease:jZe,easeVarying:NZe,end:oQe,[Symbol.iterator]:h6[Symbol.iterator]};function lQe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var uQe={time:null,delay:0,duration:250,ease:lQe};function dQe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function fQe(e){var t,n;e instanceof p6?(t=e._id,e=e._name):(t=m6(),(n=uQe).time=$3(),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])&&a6(c,e,t,l,o,n||dQe(c,t));return new p6(r,this._parents,e,t)}U4.prototype.interrupt=cZe,U4.prototype.transition=fQe;var g6=e=>()=>e;function pQe(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 _6(e,t,n){this.k=e,this.x=t,this.y=n}_6.prototype={constructor:_6,scale:function(e){return e===1?this:new _6(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _6(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 v6=new _6(1,0,0);y6.prototype=_6.prototype;function y6(e){for(;!e.__zoom;)if(!(e=e.parentNode))return v6;return e.__zoom}function b6(e){e.stopImmediatePropagation()}function x6(e){e.preventDefault(),e.stopImmediatePropagation()}function mQe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function hQe(){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 S6(){return this.__zoom||v6}function gQe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function _Qe(){return navigator.maxTouchPoints||`ontouchstart`in this}function vQe(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 C6(){var e=mQe,t=hQe,n=vQe,r=gQe,i=_Qe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=V3,l=x4(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,S6).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`,S6),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(v6.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 _6(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 _6(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 _6(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=W4(this.that).datum();l.call(e,this.that,new pQe(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=G4(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)],l6(this),s.start();x6(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=W4(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=G4(t,i),l=t.clientX,u=t.clientY;Y4(t.view),b6(t),a.mouse=[c,this.__zoom.invert(c)],l6(this),a.start();function d(e){if(x6(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]=G4(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),X4(e.view,a.moved),x6(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=G4(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);x6(r),s>0?W4(this).transition().duration(s).call(x,d,c,r):W4(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(b6(t),s=0;s<i;++s)c=r[s],l=G4(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)),l6(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(x6(e),s=0;s<a;++s)c=i[s],l=G4(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(b6(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=G4(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=W4(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:g6(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:g6(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:g6(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:g6([[+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 w6={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.`},T6=[[-1/0,-1/0],[1/0,1/0]],E6=[`Enter`,` `,`Escape`],D6={"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`},O6;(function(e){e.Strict=`strict`,e.Loose=`loose`})(O6||={});var k6;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(k6||={});var A6;(function(e){e.Partial=`partial`,e.Full=`full`})(A6||={});var j6={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},M6;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(M6||={});var N6;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(N6||={});var P6;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(P6||={});var F6={[P6.Left]:P6.Right,[P6.Right]:P6.Left,[P6.Top]:P6.Bottom,[P6.Bottom]:P6.Top};function I6(e){return e===null?null:e?`valid`:`invalid`}var L6=e=>`id`in e&&`source`in e&&`target`in e,yQe=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),R6=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),z6=(e,t=[0,0])=>{let{width:n,height:r}=u8(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},bQe=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:X6(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):R6(n)?n:t.nodeLookup.get(n.id)),J6(e,i?Q6(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),B6=(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=J6(n,Q6(e)),r=!0)}),r?X6(n):{x:0,y:0,width:0,height:0}},V6=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...i8(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=e8(s,Z6(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},xQe=(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 SQe(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 CQe({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=s8(B6(SQe(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 H6({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`,w6.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&l8(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=l8(d)?W6(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,w6.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 wQe({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=xQe(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 U6=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),W6=(e={x:0,y:0},t,n)=>({x:U6(e.x,t[0][0],t[1][0]-(n?.width??0)),y:U6(e.y,t[0][1],t[1][1]-(n?.height??0))});function G6(e,t,n){let{width:r,height:i}=u8(n),{x:a,y:o}=n.internals.positionAbsolute;return W6(e,[[a,o],[a+r,o+i]],t)}var K6=(e,t,n)=>e<t?U6(Math.abs(e-t),1,t)/t:e>n?-U6(Math.abs(e-n),1,t)/t:0,q6=(e,t,n=15,r=40)=>[K6(e.x,r,t.width-r)*n,K6(e.y,r,t.height-r)*n],J6=(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)}),Y6=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),X6=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Z6=(e,t=[0,0])=>{let{x:n,y:r}=R6(e)?e.internals.positionAbsolute:z6(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}},Q6=(e,t=[0,0])=>{let{x:n,y:r}=R6(e)?e.internals.positionAbsolute:z6(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)}},$6=(e,t)=>X6(J6(Y6(e),Y6(t))),e8=(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)},t8=e=>n8(e.width)&&n8(e.height)&&n8(e.x)&&n8(e.y),n8=e=>!isNaN(e)&&isFinite(e),TQe=(e,t)=>{},r8=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),i8=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?r8(s,o):s},a8=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function o8(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 EQe(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=o8(e,n),i=o8(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=o8(e.top??e.y??0,n),i=o8(e.bottom??e.y??0,n),a=o8(e.left??e.x??0,t),o=o8(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 DQe(e,t,n,r,i,a){let{x:o,y:s}=a8(e,[t,n,r]),{x:c,y:l}=a8({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 s8=(e,t,n,r,i,a)=>{let o=EQe(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=U6(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=DQe(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}},c8=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function l8(e){return e!=null&&e!==`parent`}function u8(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function d8(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function f8(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 p8(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function OQe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function kQe(e){return{...D6,...e||{}}}function m8(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=y8(e),s=i8({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?r8(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var h8=e=>({width:e.offsetWidth,height:e.offsetHeight}),g8=e=>e?.getRootNode?.()||window?.document,AQe=[`INPUT`,`SELECT`,`TEXTAREA`];function _8(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?AQe.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var v8=e=>`clientX`in e,y8=(e,t)=>{let n=v8(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)}},b8=(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,...h8(t)}})};function x8({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 S8(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function C8({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case P6.Left:return[t-S8(t-r,a),n];case P6.Right:return[t+S8(r-t,a),n];case P6.Top:return[t,n-S8(n-i,a)];case P6.Bottom:return[t,n+S8(i-n,a)]}}function w8({sourceX:e,sourceY:t,sourcePosition:n=P6.Bottom,targetX:r,targetY:i,targetPosition:a=P6.Top,curvature:o=.25}){let[s,c]=C8({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=C8({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=x8({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 T8({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 jQe({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 MQe({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=J6(Q6(e),Q6(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),e8({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},X6(a))>0}var NQe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,PQe=(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)),FQe=(e,t,n={})=>{if(!e.source||!e.target)return w6.error006(),t;let r=n.getEdgeId||NQe,i;return i=L6(e)?{...e}:{...e,id:r(e)},PQe(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function E8({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=T8({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var D8={[P6.Left]:{x:-1,y:0},[P6.Right]:{x:1,y:0},[P6.Top]:{x:0,y:-1},[P6.Bottom]:{x:0,y:1}},IQe=({source:e,sourcePosition:t=P6.Bottom,target:n})=>t===P6.Left||t===P6.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},O8=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function LQe({source:e,sourcePosition:t=P6.Bottom,target:n,targetPosition:r=P6.Top,center:i,offset:a,stepPosition:o}){let s=D8[t],c=D8[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=IQe({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]=T8({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 RQe(e,t,n,r){let i=Math.min(O8(e,t)/2,O8(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 k8({sourceX:e,sourceY:t,sourcePosition:n=P6.Bottom,targetX:r,targetY:i,targetPosition:a=P6.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=LQe({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+=RQe(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 A8(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zQe(e){let{sourceNode:t,targetNode:n}=e;if(!A8(t)||!A8(n))return null;let r=t.internals.handleBounds||j8(t.handles),i=n.internals.handleBounds||j8(n.handles),a=N8(r?.source??[],e.sourceHandle),o=N8(e.connectionMode===O6.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,w6.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||P6.Bottom,c=o?.position||P6.Top,l=M8(t,a,s),u=M8(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function j8(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 M8(e,t,n=P6.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??u8(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case P6.Top:return{x:i+o/2,y:a};case P6.Right:return{x:i+o,y:a+s/2};case P6.Bottom:return{x:i+o/2,y:a+s};case P6.Left:return{x:i,y:a+s/2}}}function N8(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function P8(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function BQe(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=P8(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 F8=1e3,VQe=10,I8={nodeOrigin:[0,0],nodeExtent:T6,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},HQe={...I8,checkEquality:!0};function L8(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function UQe(e,t,n){let r=L8(I8,n);for(let n of e.values())if(n.parentId)B8(n,e,t,r);else{let e=W6(z6(n,r.nodeOrigin),l8(n.extent)?n.extent:r.nodeExtent,u8(n));n.internals.positionAbsolute=e}}function WQe(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 R8(e){return e===`manual`}function z8(e,t,n,r={}){let i=L8(HQe,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!R8(i.zIndexMode)?F8: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=W6(z6(u,i.nodeOrigin),l8(u.extent)?u.extent:i.nodeExtent,u8(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:WQe(u,e),z:V8(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&&B8(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function GQe(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 B8(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=L8(I8,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}GQe(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*VQe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=KQe(e,u,o,s,a&&!R8(c)?F8: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 V8(e,t,n){let r=n8(e.zIndex)?e.zIndex:0;return R8(n)?r:r+(e.selected?t:0)}function KQe(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=u8(e),l=z6(e,n),u=l8(e.extent)?W6(l,e.extent,c):l,d=W6({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=G6(d,c,t));let f=V8(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function H8(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=$6(a.get(n.parentId)?.expandedRect??Z6(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=u8(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 qQe(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=h8(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=l8(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=G6(h,s,t.get(e.parentId)):m&&(h=W6(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:b8(`source`,r.nodeElement,p,d,e.id),target:b8(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&B8(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:Z6(g,i)}))}}if(f.length>0){let e=H8(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function JQe({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 U8(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 W8(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}`;U8(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),U8(`target`,s,c,e,i,o),t.set(r.id,r)}}function G8(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:G8(n,t):!1}function K8(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 YQe(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!G8(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 q8({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 XQe({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=r8(a,t);return{x:o.x-a.x,y:o.y-a.y}}function ZQe({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=W4(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?Y6(B6(s)):null,x=v&&l?XQe({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)}:r8(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}=H6({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]=q8({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]=q6(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=m8(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=YQe(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=q8({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=$4().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=m8(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=y8(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=m8(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=y8(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=y8(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]=q8({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||!K8(t,`.${g}`,v))&&(!_||K8(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function QQe(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())e8(i,Z6(e))>0&&r.push(e);return r}var $Qe=250;function e$e(e,t,n,r){let i=[],a=1/0,o=QQe(e,n,t+$Qe);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}=M8(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 J8(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,...M8(o,c,c.position,!0)}:c}function Y8(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function t$e(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var X8=()=>!0;function n$e(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:_=X8,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=g8(e.target),E=0,D,{x:O,y:k}=y8(e),A=Y8(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=J8(i,A,r,c,t);if(!N)return;let P=y8(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=q6(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:M8(te,z,P6.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:te,to:P,toHandle:null,toPosition:F6[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}=y8(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=y8(e,j),D=e$e(i8(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=Z8(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=t$e(!!D,s.isValid);let u=c.get(i),f=u?M8(u,z,P6.Left,!0):B.from,p={...B,from:f,isValid:L,to:s.toHandle&&L?a8({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:F6[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 Z8(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=X8,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}=y8(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=Y8(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===O6.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=J8(t,e,a,u,n,!0)}return _}var Q8={onPointerDown:n$e,isValid:Z8};function r$e({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=W4(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&&c8()?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=C6().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:G4}}var $8=e=>({x:e.x,y:e.y,zoom:e.k}),e5=({x:e,y:t,zoom:n})=>v6.translate(e,t).scale(n),t5=(e,t)=>e.target.closest(`.${t}`),n5=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),i$e=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,r5=(e,t=0,n=i$e,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},i5=e=>{let t=e.ctrlKey&&c8()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function a$e({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(t5(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=G4(u),t=d*2**i5(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===k6.Vertical?0:u.deltaX*f,m=i===k6.Horizontal?0:u.deltaY*f;!c8()&&u.shiftKey&&i!==k6.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=$8(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 o$e({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=t5(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function s$e({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=$8(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 c$e({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&n5(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,$8(a.transform))}}function l$e({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&n5(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=$8(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function u$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`&&(t5(d,`${l}-flow__node`)||t5(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||t5(d,s)&&m||t5(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 d$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=C6().scaleExtent([t,n]).translateExtent(r),f=W4(e).call(d);v({x:i.x,y:i.y,zoom:U6(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(i5);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?P3:V3).transform(r5(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:!n8(E)||E<0?0:E);let k=O?a$e({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):o$e({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=s$e({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=c$e({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=l$e({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=u$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=e5(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=e5(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=e5(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?y6(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`?P3:V3).scaleTo(r5(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`?P3:V3).scaleBy(r5(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=!n8(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 a5;(function(e){e.Line=`line`,e.Handle=`handle`})(a5||={});function f$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 o5(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 s5(e,t){return Math.max(0,t-e)}function c5(e,t){return Math.max(0,e-t)}function l5(e,t,n){return Math.max(0,t-e,e-n)}function u5(e,t){return e?!t:t}function p$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=l5(E,h,g),j=l5(D,_,v);if(o){let e=0,t=0;c&&w<0?e=s5(y+w+O,o[0][0]):!c&&w>0&&(e=c5(y+E+O,o[1][0])),l&&T<0?t=s5(b+T+k,o[0][1]):!l&&T>0&&(t=c5(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=c5(y+w,s[0][0]):!c&&w<0&&(e=s5(y+E,s[1][0])),l&&T>0?t=c5(b+T,s[0][1]):!l&&T<0&&(t=s5(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=l5(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?c5(b+k+E/C,o[1][1])*C:s5(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?s5(b+E/C,s[1][1])*C:c5(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=l5(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?c5(y+D*C+O,o[1][0])/C:s5(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?s5(y+D*C,s[1][0])/C:c5(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=(u5(c,l)?-w:w)/C:w=(u5(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 d5={width:0,height:0,x:0,y:0},m$e={...d5,pointerX:0,pointerY:0,aspectRatio:1};function h$e(e){return[[0,0],[e.measured.width,e.measured.height]]}function g$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 _$e({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=W4(e),o={controlDirection:o5(`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={...d5},h={...m$e};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:o5(e)};let g,_=null,v=[],y,b,x,S=!1,C=$4().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}=m8(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`?h$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=g$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=m8(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}=p$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=f$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 f5=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},v$e=e=>e?f5(e):f5,{useDebugValue:y$e}=C.default,{useSyncExternalStoreWithSelector:b$e}=KC.default,x$e=e=>e;function p5(e,t=x$e,n){let r=b$e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return y$e(r),r}var m5=(e,t)=>{let n=v$e(e),r=(e,r=t)=>p5(n,e,r);return Object.assign(r,n),r},S$e=(e,t)=>e?m5(e,t):m5;function h5(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 g5=(0,C.createContext)(null),C$e=g5.Provider,_5=w6.error001();function v5(e,t){let n=(0,C.useContext)(g5);if(n===null)throw Error(_5);return p5(n,e,t)}function y5(){let e=(0,C.useContext)(g5);if(e===null)throw Error(_5);return(0,C.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var b5={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%)`},x5=`react-flow__node-desc`,S5=`react-flow__edge-desc`,T$e=`react-flow__aria-live`,E$e=e=>e.ariaLiveMessage,D$e=e=>e.ariaLabelConfig;function O$e({rfId:e}){let t=v5(E$e);return(0,G.jsx)(`div`,{id:`${T$e}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:w$e,children:t})}function k$e({rfId:e,disableKeyboardA11y:t}){let n=v5(D$e);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{id:`${x5}-${e}`,style:b5,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,G.jsx)(`div`,{id:`${S5}-${e}`,style:b5,children:n[`edge.a11yDescription.default`]}),!t&&(0,G.jsx)(O$e,{rfId:e})]})}var C5=(0,C.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,G.jsx)(`div`,{className:b4([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));C5.displayName=`Panel`;function A$e({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,G.jsx)(C5,{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 j$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}},w5=e=>e.id;function M$e(e,t){return h5(e.selectedNodes.map(w5),t.selectedNodes.map(w5))&&h5(e.selectedEdges.map(w5),t.selectedEdges.map(w5))}function N$e({onSelectionChange:e}){let t=y5(),{selectedNodes:n,selectedEdges:r}=v5(j$e,M$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 P$e=e=>!!e.onSelectionChangeHandlers;function F$e({onSelectionChange:e}){let t=v5(P$e);return e||t?(0,G.jsx)(N$e,{onSelectionChange:e}):null}var T5=typeof window<`u`?C.useLayoutEffect:C.useEffect,E5=[0,0],I$e={x:0,y:0,zoom:1},D5=[...`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`],L$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}),O5={translateExtent:T6,nodeOrigin:E5,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function R$e(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=v5(L$e,h5),l=y5();T5(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=O5,s()}),[]);let u=(0,C.useRef)(O5);return T5(()=>{for(let s of D5){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:kQe(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},D5.map(t=>e[t])),null}function k5(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function z$e(e){let[t,n]=(0,C.useState)(e===`system`?null:e);return(0,C.useEffect)(()=>{if(e!==`system`){n(e);return}let t=k5(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?k5()?.matches?`dark`:`light`:t}var A5=typeof document<`u`?document:null;function j5(e=null,t={target:A5,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(`+`,`
459
+ `,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=z2(R2(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=z2(R2(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 H2(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new P2||null,prettyErrors:t}}function Cqe(e,t={}){let{lineCounter:n,prettyErrors:r}=H2(t),i=new V2(n?.addNewLine),a=new y2(t),o=Array.from(a.compose(i.parse(e)));if(r&&n)for(let t of o)t.errors.forEach(t2(e,n)),t.warnings.forEach(t2(e,n));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function U2(e,t={}){let{lineCounter:n,prettyErrors:r}=H2(t),i=new V2(n?.addNewLine),a=new y2(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 $0(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(t2(e,n)),o.warnings.forEach(t2(e,n))),o}function wqe(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=U2(e,n);if(!i)return null;if(i.warnings.forEach(e=>Y1(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 Tqe(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 t1(e)&&!r?e.toString(n):new X0(e,r,n).toString(n)}var Eqe=c({Alias:()=>E1,CST:()=>_qe,Composer:()=>y2,Document:()=>X0,Lexer:()=>N2,LineCounter:()=>P2,Pair:()=>n0,Parser:()=>V2,Scalar:()=>k1,Schema:()=>Y0,YAMLError:()=>Q0,YAMLMap:()=>o0,YAMLParseError:()=>$0,YAMLSeq:()=>c0,YAMLWarning:()=>e2,isAlias:()=>e1,isCollection:()=>o1,isDocument:()=>t1,isMap:()=>n1,isNode:()=>s1,isPair:()=>r1,isScalar:()=>i1,isSeq:()=>a1,parse:()=>wqe,parseAllDocuments:()=>Cqe,parseDocument:()=>U2,stringify:()=>Tqe,visit:()=>f1,visitAsync:()=>m1});function Dqe(e){let t=null;try{t=Eqe.parse(e.doc.toString())}catch{}let n=aq(e,tq.YAML);return{data:t,pointers:n}}var W2=e=>{switch(e){case tq.JSON:return mKe;case tq.JSON5:return gKe;case tq.YAML:return Dqe}};function Oqe(e){return Object.entries(e)}function G2(e,t){if(typeof e==`string`||typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>G2(e,t));if(e instanceof Map){let n=new Map;for(let[r,i]of e){let e=r,a=G2(i,t);n.set(e,a)}return n}if(e instanceof Set){let n=new Set;for(let r of e){let e=G2(r,t);n.add(e)}return n}let n={};function r(e,r,i,a){i===e&&a===r?n[i]=G2(r,t):n[i]=a}for(let[n,i]of Oqe(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 kqe=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},Aqe=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 K2(e){return!(!e||wq(e)||e.name===`UnknownPropertyError`||e.type===`undefined`)}var jqe=class{constructor(e){this.opts=e,this.originalSchema=null,this.schema=null,this.laxSchema=null,this.mode=tq.JSON,this.mode=e.mode??tq.JSON,this.parser=this.opts?.jsonParser??W2(this.mode)}doComplete(e){let t=vq(e.state);if(this.originalSchema!==t&&(this.schema=Y2(t,t)??t,this.laxSchema=Nqe(this.schema)),!this.schema||!this.laxSchema)return[];ZK.log(`xxx`,`trying with original schema`);let n=this.doCompleteForSchema(e,this.schema);return n.options.length===0?(ZK.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=oq(e.state,e.pos),a=e.state.sliceDoc(i.from,e.pos).replace(/^(["'])/,``);if(ZK.log(`xxx`,`node`,i,`prefix`,a,`ctx`,e),!(uq(i,this.mode)||dq(i,this.mode))&&!e.explicit)return ZK.log(`xxx`,`no completions for non-word/primitive`,i),n;let o=cq(e.state.doc,i),s=cq(e.state.doc,i,!1);if(i&&(uq(i,this.mode)||dq(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;ZK.log(`xxx`,`overwriteStart after`,a,`ctx.pos`,e.pos,`word`,t,`currentWord`,o,`=>`,r[a-1],`..`,r[a],`..`,r),n.from=i.name===QK.INVALID?t?.from??e.pos:a,n.to=e.pos}let c=new Aqe,l=!0,u=gq(i,QK.PROPERTY_NAME,this.mode);if(u&&(ZK.log(`xxx`,`closestPropertyNameNode`,u,`node`,i),i=u),dq(i,this.mode)){ZK.log(`xxx`,`isPropertyNameNode`,i);let e=i.parent;if(e){let t=mq(e,this.mode);l=!t||t.name===QK.INVALID&&t.from-t.to===0||(t.parent?fq(t.parent).length<=1:!1),ZK.log(`xxx`,`addValue`,l,mq(e,this.mode),i),i=gq(e,QK.OBJECT,this.mode)??null}}if(ZK.log(`xxx`,i,o,e,`node at pos`,oq(e.state,e.pos)),i&&[QK.OBJECT,QK.JSON_TEXT].includes(nq(i.name,this.mode))&&(dq(oq(e.state,e.pos),this.mode)||u)){if(i.from===e.pos)return ZK.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);ZK.log(`xxx`,`getValueCompletions res`,n)}return n.options=Array.from(c.completions.values()).filter(e=>sq(e.label).startsWith(a)),ZK.log(`xxx`,`result`,n,`prefix`,a,`collector.completions`,c.completions,`reservedKeys`,c.reservedKeys),n}applySnippetCompletion(e){return NLe(typeof e.apply==`string`?e.apply:e.label,e)}getPropertyCompletions(e,t,n,r,i,a){let o=hRe(n,QK.PROPERTY,this.mode);ZK.log(`xxx`,`getPropertyCompletions`,n,t,o),o.forEach(e=>{let n=cq(t.state.doc,pq(e,QK.PROPERTY_NAME,this.mode));r.reserve(sq(n))});let s=this.getSchemas(e,t);ZK.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:()=>EY(`div`,{inner:G$(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&&=Y2(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 tq.JSON5:o=`{#{}}`;break;case tq.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)&&(ZK.log(`xxx`,`value`,o,`nValueProposals`,s,i),o=`#{}`),a+o}getInsertTextForPropertyName(e,t){switch(this.mode){case tq.JSON5:case tq.YAML:return t.startsWith(`"`)?`"${e}"`:t.startsWith(`'`)?`'${e}'`:e;default:return`"${e}"`}}getInsertTextForString(e,t=`#`){switch(this.mode){case tq.JSON5:return`'${t}{${e}}'`;case tq.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=BH(t.state).resolveInner(t.pos,-1),a=null,o;if(ZK.log(`xxx`,`getValueCompletions`,i,t),i&&uq(i,this.mode)&&(a=i,i=i.parent),!i){this.addSchemaValueCompletions(e,n,r);return}if(nq(i.name,this.mode)===QK.PROPERTY){let e=pq(i,QK.PROPERTY_NAME,this.mode);e&&(o=cq(t.state.doc,e),i=i.parent)}if(ZK.log(`xxx`,`node`,i,`parentKey`,o),i&&(o!==void 0||nq(i.name,this.mode)===QK.ARRAY)){let s=this.getSchemas(e,t);for(let e of s){if(typeof e!=`object`)return;if(nq(i.name,this.mode)===QK.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=hq(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?cq(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 TY(e),i=iq(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=q2(e,n,i);if(t!=null)return[t]}let a=i?.replace(/\/[^/]*$/,``);a===``&&(a=void 0);let o=q2(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),ZK.log(`xxxx`,`draft.getSchema`,l,`data`,n,`pointer`,i,`pointerPointsToKnownProperty`,c),wq(l)&&(l=l.data?.schema),!K2(l)&&o?[o]:(K2(l)||(l=r.getSchema({pointer:a}),i=a),ZK.log(`xxx`,`pointer..`,JSON.stringify(i)),!K2(l)&&(!i||i===`/`)&&(l=Y2(e,e)??e),ZK.log(`xxx`,`subSchema..`,l),l?Array.isArray(l.allOf)?[l,...l.allOf.map(t=>Y2(t,e))]:Array.isArray(l.oneOf)?[l,...l.oneOf.map(t=>Y2(t,e))]:Array.isArray(l.anyOf)?[l,...l.anyOf.map(t=>Y2(t,e))]:[l]:[])}getAppliedValue(e){let t=sq(JSON.stringify(e));switch(this.mode){case tq.JSON5:return{label:t,apply:pRe(JSON.stringify(e))};case tq.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 Mqe(e={}){let t=new jqe(e);return function(e){return t.doComplete(e)}}function Nqe(e){return G2(e,(e,t)=>e===`additionalProperties`&&t===!1||e===`required`&&Array.isArray(t)||e===`unevaluatedProperties`&&t===!1||e===`unevaluatedItems`&&t===!1?[]:[e,t])}function q2(e,t,n){let r=new TY(e),i=r.getSchema({pointer:n,data:t??void 0});if(!K2(i))return;let a=J2(r,i),o={};for(let e of a){let i=Fqe(n,e),a=r.getSchema({pointer:i,data:t??void 0});K2(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=kqe(s,[`allOf`,`anyOf`,`oneOf`]);return Object.assign(Object.assign({},d),{properties:o})}function J2(e,t){if(t=Y2(t,e.rootSchema),typeof t!=`object`||!t)return[];let n=[];function r(t){let r=J2(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 Y2(e,t){if(typeof e==`object`&&e.$ref){let n=Pqe(t,e.$ref);if(typeof n==`object`){let t=Object.assign(Object.assign({},e),n);return Reflect.deleteProperty(t,`$ref`),t}}return e}function Pqe(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 Fqe(e,t){return e===void 0?`/${t}`:`${e}/${t}`}var X2=(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(` `)},Iqe=e=>e?.data?.pointer&&e?.data?.pointer!==`#`?e.data.pointer.slice(1):e?.data?.property?`/${e.data.property}`:``,Lqe=e=>e.startState.field(_q)!==e.state.field(_q);function Rqe(e){let t=new Bqe(e);return e=>t.doValidation(e)}var zqe=[`NoAdditionalPropertiesError`,`RequiredPropertyError`,`InvalidPropertyNameError`,`ForbiddenPropertyError`,`UndefinedValueError`],Bqe=class{constructor(e){this.options=e,this.schema=null,this.mode=tq.JSON,this.rewriteError=e=>{let t=e?.data?.errors;return e.code===`one-of-error`&&t?.length?`Expected one of ${X2(t,e=>e.data.expected)}`:e.code===`type-error`?`Expected \`${e?.data?.expected&&Array.isArray(e?.data?.expected)?X2(e?.data?.expected):e?.data?.expected}\` but received \`${e?.data?.received}\``:e.message.replaceAll("in `#` ",``).replaceAll("at `#`",``).replaceAll(`/`,`.`).replaceAll(`#.`,``)},this.mode=this.options?.mode??tq.JSON,this.parser=this.options?.jsonParser??W2(this.mode)}get schemaTitle(){return this.schema?.getSchema()?.title??`json-schema`}doValidation(e){let t=vq(e.state);if(!t||(this.schema=new xY(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 ZK.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=EY(`div`,{});return e.innerHTML=G$(n),e}})},i=Iqe(t),a=n.pointers.get(i);if(t.name===`MaxPropertiesError`||t.name===`MinPropertiesError`||i===``)r();else if(a){let n=zqe.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=EY(`div`,{});return e.innerHTML=G$(r),e},severity:`error`,source:this.schemaTitle})}else r();return e},[]):[]}};function Vqe(e){let t=new Uqe(e);return async function(e,n,r){return t.doHover(e,n,r)}}function Hqe(e){if(e.type)return e.$ref?`${e.$ref} (${e.type})`:e.type;if(e.$ref)return`${e.$ref}`}function Z2(e,t,n){return`${t}: ${X2(e[t].map(e=>{try{let{data:t}=n.resolveRef({data:e,pointer:e.$ref});return Hqe(t||e)}catch{return e.type}}))}`}var Uqe=class{constructor(e){this.opts=e,this.schema=null,this.mode=tq.JSON,this.opts=Object.assign({parser:JSON.parse},this.opts),this.mode=this.opts?.mode??tq.JSON}getDataForCursor(e,t,n){let r=vq(e.state);if(!r)return null;this.schema=new xY(r);let i=iq(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 wq(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?EY(`div`,{class:`cm6-json-schema-hover`},[EY(`div`,{class:`cm6-json-schema-hover--description`,inner:G$(t,!1)}),EY(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[EY(`div`,{class:`cm6-json-schema-hover--code`,inner:G$(n,!1)})])]):EY(`div`,{class:`cm6-json-schema-hover`},[EY(`div`,{class:`cm6-json-schema-hover--code-wrapper`},[EY(`code`,{class:`cm6-json-schema-hover--code`,inner:G$(n,!1)})])])}getHoverTexts(e,t){let n=``,r=null,{schema:i}=e;return i.oneOf&&(n=Z2(i,`oneOf`,t)),i.anyOf&&(n=Z2(i,`anyOf`,t)),i.allOf&&(n=Z2(i,`allOf`,t)),i.type&&(n=Array.isArray(i.type)?X2(i.type):i.type),i.$ref&&(n=` Reference: ${i.$ref}`),i.enum&&(n=`\`enum\`: ${X2(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(ZK.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 ZK.log(e),null}}},Wqe=e=>(0,G.jsx)(oy,{disablePadding:!0,children:e.validationErrors.map((e,t)=>(0,G.jsx)(ly,{disableGutters:!0,disablePadding:!0,children:(0,G.jsxs)(Yv,{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()))}),Q2=e=>{let t;try{t=JSON.parse(e)}catch{t=void 0}return t};function Gqe({schema:e,customValidate:t}){let n=(0,C.useMemo)(()=>new xOe.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 Kqe=e=>{let t=qqe(),[n,r]=(0,C.useState)(()=>JSON.stringify(e.value,null,2)),i=Gqe(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=Q2(e),n=i(t);s(t,n.length===0),r(e),o(n)},[i,s]),l=()=>{let e=Q2(n);e&&r(JSON.stringify(e,null,2))};return(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsxs)(Z,{position:`relative`,children:[(0,G.jsx)(YK,{value:n,onChange:e=>c(e),extensions:[VPe(),WU(zPe(),{delay:100}),WU(Rqe(),{delay:100,needsRefresh:Lqe}),MU.data.of({autocomplete:Mqe({mode:`json4`})}),gH(Vqe()),vRe(e.schema)],theme:t,height:`400px`}),(0,G.jsx)(xv,{sx:{position:`absolute`,right:`0`,bottom:`0`},onClick:()=>l(),children:`Prettify`})]}),a.length>0&&(0,G.jsx)(Wh,{severity:`error`,variant:`outlined`,children:(0,G.jsx)(Wqe,{validationErrors:a})})]})};function qqe(){return wm().palette.mode===`dark`?lFe:aFe}var Jqe=[{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`}],Yqe=({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&&TE(e).then(t=>{a(t),t&&s(`${EE(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 Ege(e,i),a(!0),s(`${EE(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 Dge(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)(Yv,{spacing:2,children:[(0,G.jsxs)(Iv,{fullWidth:!0,size:`small`,children:[(0,G.jsx)(Ux,{id:`icon-select-label`,children:`Bridge Icon`}),(0,G.jsx)(wS,{labelId:`icon-select-label`,value:t??``,label:`Bridge Icon`,onChange:e=>m(e.target.value),disabled:i,children:Jqe.map(e=>(0,G.jsx)(TS,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(DS,{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)(Yv,{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)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(Bhe,{}),onClick:()=>r.current?.click(),disabled:c,children:c?`Uploading...`:`Upload Image`}),i&&(0,G.jsx)(xv,{variant:`outlined`,size:`small`,color:`error`,startIcon:(0,G.jsx)(RS,{}),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.`})]})},$2={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`,weather:`Sensor`},e4=e=>{try{return JSON.parse(e)}catch{return}};function Xqe({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=e4(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??e4(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 (standalone device node) 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=>!$2[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)(xv,{variant:`outlined`,startIcon:t?(0,G.jsx)(zh,{size:16}):(0,G.jsx)(sge,{}),onClick:d,disabled:t,size:`small`,children:t?`Loading...`:`Preview Matching Entities`}),a&&(0,G.jsx)(Wh,{severity:`error`,sx:{mt:1},children:a}),(0,G.jsx)(iy,{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)(Nv,{label:`Showing first 100`,size:`small`,color:`warning`,variant:`outlined`})]}),p.length>0&&(0,G.jsx)(Yv,{spacing:.5,sx:{mb:1.5},children:p.map(e=>(0,G.jsx)(Wh,{severity:`warning`,variant:`outlined`,icon:e.includes(`vacuum`)?(0,G.jsx)(_v,{fontSize:`small`}):(0,G.jsx)(kb,{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)(Nv,{label:`${e}: ${t}${$2[e]?` → ${$2[e]}`:``}`,size:`small`,variant:`outlined`,color:$2[e]?`default`:`warning`},e))}),(0,G.jsx)(oy,{dense:!0,sx:{maxHeight:200,overflow:`auto`,bgcolor:`background.paper`,borderRadius:1,border:1,borderColor:`divider`},children:r.entities.map(e=>(0,G.jsx)(ly,{divider:!0,children:(0,G.jsx)(py,{primary:e.friendly_name||e.entity_id,secondary:`${e.entity_id}${$2[e.domain]?` → ${$2[e.domain]}`:``}`,primaryTypographyProps:{variant:`body2`},secondaryTypographyProps:{variant:`caption`,fontFamily:`monospace`}})},e.entity_id))}),(0,G.jsx)(xv,{size:`small`,onClick:()=>c(!1),sx:{mt:1},children:`Hide Preview`})]})})]})}var Zqe=iF().ObjectFieldTemplate;function Qqe(e){return(e.fieldPathId?.$id??``)===`root_filter`?(0,G.jsx)($qe,{...e}):(0,G.jsx)(Zqe,{...e})}function $qe(e){let t=(e.formData?.include?.length??0)+(e.formData?.exclude?.length??0),[n,r]=(0,C.useState)(t>0);return(0,G.jsxs)(aC,{expanded:n,onChange:(e,t)=>r(t),variant:`outlined`,disableGutters:!0,sx:{borderRadius:2,"&::before":{display:`none`},overflow:`hidden`},children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),sx:{px:2,"& .MuiAccordionSummary-content":{alignItems:`center`,gap:1.5}},children:[(0,G.jsx)(wb,{fontSize:`small`,color:`action`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:600,children:`Entity Filters`}),(0,G.jsx)(Bx,{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)(oC,{sx:{px:2,pb:2},children:e.properties.map(e=>(0,G.jsx)(`div`,{children:e.content},e.name))})]})}function eJe(e){let t=(0,C.useRef)(e),n=t.current;return t.current=e,n}function t4(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=eJe(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)(Nv,{label:t.length,size:`small`,color:`default`,sx:{height:22,fontSize:`0.75rem`}}),n&&(0,G.jsx)(xv,{size:`small`,startIcon:(0,G.jsx)(yb,{}),onClick:r,children:`Add`})]})]}),t.length>3&&(0,G.jsx)(OS,{size:`small`,fullWidth:!0,placeholder:`Search rules...`,value:l,onChange:e=>u(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(tF,{position:`start`,children:(0,G.jsx)(gE,{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)(Yv,{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)(Ahe,{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)(Nv,{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)(iy,{in:a,children:(0,G.jsx)(Z,{sx:{px:2,pb:1.5,pt:.5},children:t[e]})})]},e)})})]})}var tJe=new Set([``,`pattern`,`regex`]);function nJe(e){let{schema:t,formData:n,onChange:r,disabled:i,readonly:a,fieldPathId:o}=e,s=n??{},c=s.type??``,l=s.value??``,u=i||a,d=t.properties??{},f=(d.type?.oneOf??[]).filter(e=>typeof e.const==`string`),p=d.value?.title??`Value`,m=f.find(e=>e.const===c),h=(0,C.useCallback)(e=>r({...s,type:e},o.path),[s,r,o]),g=(0,C.useCallback)(e=>r({...s,value:e},o.path),[s,r,o]),_=tJe.has(c)&&!u;return(0,G.jsxs)(Yv,{spacing:2,sx:{pt:1},children:[(0,G.jsxs)(Iv,{fullWidth:!0,size:`small`,disabled:u,children:[(0,G.jsx)(Ux,{id:`${o.path}-type`,children:`Type`}),(0,G.jsx)(wS,{labelId:`${o.path}-type`,label:`Type`,value:c,onChange:e=>h(e.target.value),children:f.map(e=>(0,G.jsx)(TS,{value:e.const,children:e.title??e.const},e.const))})]}),m?.description&&(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:m.description}),_?(0,G.jsx)(ZS,{value:l,onChange:g,label:p,placeholder:`sensor.living_room_*`,helperText:`Search or type an entity ID. Wildcards and regex still work.`,margin:`none`}):(0,G.jsx)(OS,{fullWidth:!0,size:`small`,label:p,value:l,disabled:u,onChange:e=>g(e.target.value),helperText:d.value?.description})]})}function rJe(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)(Hv,{container:!0,spacing:2,children:Object.entries(s).map(([e,t])=>{let r=n[e]??t.default??!1;return(0,G.jsx)(Hv,{size:{xs:12,sm:6,lg:4},children:(0,G.jsx)(Sv,{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)(wv,{onClick:()=>{!i&&!a&&c(e,!r)},disabled:i||a,sx:{height:`100%`},children:(0,G.jsxs)(Tv,{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)(Nv,{label:`Active`,size:`small`,color:`primary`,variant:`outlined`,sx:{mt:.5,height:20,fontSize:`0.7rem`}})]}),(0,G.jsx)(qS,{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 n4=e=>{let{t}=Ts(),[n,r]=(0,C.useState)(`FIELDS_EDITOR`),i=()=>{r(n===`FIELDS_EDITOR`?`JSON_EDITOR`:`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. The node carries up to 10 devices; the first entity is the primary and drives the node name and type. More than one device is experimental.`}),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)(Wh,{severity:`warning`,variant:`outlined`,children:[`Please consult`,` `,(0,G.jsx)(Qv,{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)(Wh,{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)(Wh,{severity:e.severity,variant:`outlined`,children:e.message},e.message)),(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsx)(Z,{display:`flex`,justifyContent:`flex-end`,children:(0,G.jsx)(xv,{onClick:()=>i(),title:t(n===`FIELDS_EDITOR`?`bridge.jsonEditor`:`bridge.formEditor`),children:n===`FIELDS_EDITOR`?(0,G.jsx)(fge,{}):(0,G.jsx)(ege,{})})}),n===`FIELDS_EDITOR`&&(0,G.jsx)(nAe,{value:a??{},onChange:u,schema:mv,uiSchema:{icon:{"ui:widget":`hidden`},featureFlags:{"ui:field":`featureFlags`},filter:{include:{"ui:options":{ArrayFieldTemplate:t4},items:{"ui:field":`entityFilterRule`}},exclude:{"ui:options":{ArrayFieldTemplate:t4},items:{"ui:field":`entityFilterRule`}}}},customValidate:l,templates:{ObjectFieldTemplate:Qqe},fields:{featureFlags:rJe,entityFilterRule:nJe}}),n===`JSON_EDITOR`&&(0,G.jsx)(Kqe,{value:a??{},onChange:u,schema:mv,customValidate:l}),a?.filter&&(0,G.jsx)(Xqe,{filter:a.filter}),(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`subtitle1`,gutterBottom:!0,fontWeight:600,children:t(`bridge.iconLabel`)}),(0,G.jsx)(Yqe,{bridgeId:e.bridgeId,selectedIcon:a?.icon,onIconChange:d})]})}),(0,G.jsxs)(Hv,{container:!0,children:[(0,G.jsx)(Hv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(xv,{fullWidth:!0,variant:`outlined`,color:`error`,onClick:e.onCancel,children:t(`common.cancel`)})}),(0,G.jsx)(Hv,{size:{xs:0,sm:4,md:6},sx:{display:{xs:`none`,sm:`block`}}}),(0,G.jsx)(Hv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(xv,{fullWidth:!0,variant:`outlined`,disabled:!s,onClick:async()=>{s&&await e.onSave(a)},children:t(`common.save`)})})]})]})]})},iJe={name:``,featureFlags:{},filter:{include:[],exclude:[]}};function aJe(e){let t=5540;for(;e[t];)t++;return t}var oJe=()=>{let{t:e}=Ts(),t=ey(),n=Pr(),[r,i]=(0,C.useState)(),a=!!FT().content?.length,o=IT(),s=(0,C.useCallback)(e=>{i(e?.id)},[]),c=(0,C.useMemo)(()=>{if(!o)return;let e=aJe(o);if(r){let t=sv.find(e=>e.id===r);if(t)return{name:t.name,port:e,filter:{...t.filter},featureFlags:{...t.featureFlags},icon:t.icon}}return{...iJe,port:e}},[o,r]),l=RT(),u=()=>{n(-1)};return!c||!o?e(`common.loading`):(0,G.jsxs)(Yv,{spacing:4,children:[(0,G.jsx)($v,{items:[{name:e(`nav.bridges`),to:Y9.bridges},{name:e(`common.create`),to:Y9.createBridge}]}),a&&(0,G.jsx)(Wh,{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)(Qv,{href:Y9.faq.multiFabric,target:`_blank`,children:`Learn more.`})]})}),(0,G.jsx)(BE,{selectedTemplate:r,onSelect:s}),(0,G.jsx)(n4,{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`)]})},sJe=()=>{let{t:e}=Ts(),t=ey(),n=Pr(),{bridgeId:r}=Rr(),{content:i,isLoading:a}=LT(r),o=IT(),s=uhe(),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)(Yv,{spacing:4,children:[(0,G.jsx)($v,{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)(n4,{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 cJe(){let e=await fetch(`api/backup/snapshots`);return await z_(e,`Failed to fetch backups`),R_(e)}async function lJe(){let e=await fetch(`api/backup/snapshots/create`,{method:`POST`});return await z_(e,`Failed to create backup`),R_(e)}async function uJe(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 dJe(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 z_(n,`Failed to restore backup`),R_(n)}async function fJe(e){await z_(await fetch(`api/backup/snapshots/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete backup`)}async function pJe(){let e=await fetch(`api/backup/settings`);return await z_(e,`Failed to fetch backup settings`),R_(e)}async function mJe(e){let t=await fetch(`api/backup/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return await z_(t,`Failed to update backup settings`),R_(t)}function hJe(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function r4(){let{t:e}=Ts(),[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([cJe(),pJe()]);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 lJe(),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 uJe(e)}catch(e){i(e instanceof Error?e.message:`Failed to download backup`)}},z=async t=>{n(!0),i(null);try{let n=await dJe(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 fJe(e),P(null),await L()}catch(e){i(e instanceof Error?e.message:`Failed to delete backup`)}},B=async e=>{try{A(await mJe(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)(Sv,{children:[(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,children:[(0,G.jsx)(YT,{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)(Wh,{severity:`error`,sx:{mb:2},onClose:()=>i(null),children:r}),a&&(0,G.jsx)(Wh,{severity:`success`,sx:{mb:2},onClose:()=>o(null),children:a}),(0,G.jsxs)(Hv,{container:!0,spacing:2,children:[(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(YT,{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)(xv,{variant:`contained`,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):(0,G.jsx)(YT,{}),onClick:()=>V(!1),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.configBackup`)})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(_E,{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)(xv,{variant:`contained`,color:`warning`,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):(0,G.jsx)(YT,{}),onClick:()=>V(!0),disabled:t,fullWidth:!0,sx:{mt:2},children:e(`backup.fullBackup`)})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(mE,{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)(xv,{variant:`outlined`,color:`info`,startIcon:(0,G.jsx)(mE,{}),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)(Xb,{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)(YT,{color:`primary`}),(0,G.jsx)(Q,{variant:`subtitle1`,fontWeight:`bold`,children:e(`backup.storedBackups`)}),T.length>0&&(0,G.jsx)(Nv,{label:T.length,size:`small`,color:`primary`,variant:`outlined`})]}),(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:F?(0,G.jsx)(zh,{size:16,color:`inherit`}):(0,G.jsx)(yb,{}),onClick:R,disabled:F,children:e(`backup.createSnapshot`)})]}),D?(0,G.jsx)(Z,{display:`flex`,justifyContent:`center`,p:2,children:(0,G.jsx)(zh,{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)(oy,{dense:!0,children:T.map(t=>(0,G.jsxs)(ly,{secondaryAction:(0,G.jsxs)(Z,{display:`flex`,gap:.5,children:[(0,G.jsx)(vb,{title:e(`backup.downloadSnapshot`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>ee(t.filename),children:(0,G.jsx)(jT,{fontSize:`small`})})}),(0,G.jsx)(vb,{title:e(`backup.restoreSnapshot`),children:(0,G.jsx)(Vh,{size:`small`,color:`warning`,onClick:()=>M(t.filename),children:(0,G.jsx)(mE,{fontSize:`small`})})}),(0,G.jsx)(vb,{title:e(`common.delete`),children:(0,G.jsx)(Vh,{size:`small`,color:`error`,onClick:()=>P(t.filename),children:(0,G.jsx)(RS,{fontSize:`small`})})})]}),children:[(0,G.jsx)(dy,{sx:{minWidth:36},children:(0,G.jsx)(YT,{fontSize:`small`,color:t.auto?`action`:`primary`})}),(0,G.jsx)(py,{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)(Nv,{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:hJe(t.sizeBytes)})]}),secondary:new Date(t.createdAt).toLocaleString()})]},t.filename))}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:2,children:[(0,G.jsx)(MT,{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)(Vv,{control:(0,G.jsx)(qS,{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)(OS,{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)(Gb,{open:_,onClose:()=>v(!1),maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Jb,{children:e(`backup.restoreTitle`)}),(0,G.jsx)(qb,{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)(Wh,{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)(oy,{dense:!0,children:s.bridges.map(e=>(0,G.jsxs)(ly,{onClick:()=>ie(e.id),sx:{cursor:`pointer`},children:[(0,G.jsx)(dy,{children:(0,G.jsx)(Av,{edge:`start`,checked:l.has(e.id),tabIndex:-1,disableRipple:!0})}),(0,G.jsx)(py,{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)(Vv,{control:(0,G.jsx)(Av,{checked:d,onChange:e=>f(e.target.checked)}),label:e(`backup.overwriteExisting`)}),(0,G.jsx)(Vv,{control:(0,G.jsx)(Av,{checked:p,onChange:e=>m(e.target.checked)}),label:e(`backup.includeMappings`)}),s?.includesIdentity&&(0,G.jsx)(Vv,{control:(0,G.jsx)(Av,{checked:h,onChange:e=>g(e.target.checked)}),label:e(`backup.restoreIdentities`)})]})]})}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>v(!1),children:e(`common.cancel`)}),(0,G.jsx)(xv,{variant:`contained`,onClick:re,disabled:t||l.size===0,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Gb,{open:y,onClose:()=>b(!1),children:[(0,G.jsxs)(Jb,{children:[(0,G.jsx)(pE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.restartRequired`)]}),(0,G.jsxs)(qb,{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)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>b(!1),children:e(`common.later`)}),(0,G.jsx)(xv,{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)(zh,{size:20,color:`inherit`}):(0,G.jsx)(pE,{}),children:e(`backup.restartNow`)})]})]}),(0,G.jsxs)(Gb,{open:j!==null,onClose:()=>M(null),children:[(0,G.jsxs)(Jb,{children:[(0,G.jsx)(mE,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmRestore`)]}),(0,G.jsxs)(qb,{children:[(0,G.jsx)(Q,{children:e(`backup.confirmRestoreMessage`,{filename:j})}),(0,G.jsx)(Wh,{severity:`warning`,sx:{mt:2},children:e(`backup.restoreWarning`)})]}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>M(null),children:e(`common.cancel`)}),(0,G.jsx)(xv,{variant:`contained`,color:`warning`,onClick:()=>j&&z(j),disabled:t,startIcon:t?(0,G.jsx)(zh,{size:20,color:`inherit`}):null,children:e(`backup.restore`)})]})]}),(0,G.jsxs)(Gb,{open:N!==null,onClose:()=>P(null),children:[(0,G.jsxs)(Jb,{children:[(0,G.jsx)(RS,{sx:{mr:1,verticalAlign:`middle`}}),e(`backup.confirmDelete`)]}),(0,G.jsx)(qb,{children:(0,G.jsx)(Q,{children:e(`backup.confirmDeleteMessage`,{filename:N})})}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>P(null),children:e(`common.cancel`)}),(0,G.jsx)(xv,{variant:`contained`,color:`error`,onClick:()=>N&&te(N),children:e(`common.delete`)})]})]})]})}var gJe=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 _Je(e={}){let{t}=Ts(),[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)(zh,{})}):o||!n?(0,G.jsx)(Wh,{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)(gv,{color:`success`}):n.status===`degraded`?(0,G.jsx)(ny,{color:`warning`}):(0,G.jsx)(Ox,{color:`error`}),(0,G.jsx)(Q,{variant:`h5`,children:t(`health.systemHealth`)}),(0,G.jsx)(Nv,{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)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(XT,{}),onClick:_,children:t(`health.exportDiagnostic`)}),(0,G.jsx)(vb,{title:t(`common.refresh`),children:(0,G.jsx)(Vh,{onClick:g,"aria-label":`Refresh health data`,children:(0,G.jsx)(fE,{})})})]})]}),(0,G.jsxs)(Hv,{container:!0,spacing:2,children:[(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{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)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.uptime`)}),(0,G.jsx)(Q,{variant:`h6`,children:gJe(n.uptime)})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:4},children:(0,G.jsxs)(Gm,{sx:{p:2},children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:t(`health.homeAssistant`)}),(0,G.jsx)(Nv,{label:n.services.homeAssistant.connected?t(`health.connected`):t(`health.disconnected`),color:n.services.homeAssistant.connected?`success`:`error`,size:`small`})]})})]}),(0,G.jsx)(Xb,{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)(cE,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.bridgeStatus`)}),(0,G.jsx)(Nv,{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)(Fx,{fontSize:`small`,color:`action`}),(0,G.jsxs)(Iv,{size:`small`,sx:{minWidth:120},children:[(0,G.jsx)(Ux,{children:t(`health.sortBy`)}),(0,G.jsxs)(wS,{value:f,label:t(`health.sortBy`),onChange:e=>m(e.target.value),children:[(0,G.jsx)(TS,{value:`name`,children:t(`common.name`)}),(0,G.jsx)(TS,{value:`created`,children:t(`health.created`)})]})]}),(0,G.jsx)(vb,{title:t(p===`asc`?`health.ascending`:`health.descending`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>h(p===`asc`?`desc`:`asc`),"aria-label":`Sort ${p===`asc`?`descending`:`ascending`}`,children:p===`asc`?(0,G.jsx)(KT,{fontSize:`small`}):(0,G.jsx)(GT,{fontSize:`small`})})})]})]}),(0,G.jsx)(Hv,{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)(Hv,{size:{xs:12,sm:6,md:6,lg:4,xl:3},sx:{display:`flex`},children:(0,G.jsx)(Sv,{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)(Tv,{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)(xb,{}),(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)(Nv,{label:e.status.toUpperCase(),color:e.status===`running`?`success`:e.status===`failed`?`error`:`warning`,size:`small`}),e.status===`failed`&&(0,G.jsx)(vb,{title:t(`bridge.restart`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>v(e.id),children:(0,G.jsx)(JT,{})})})]})]}),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)(Nv,{label:`${t(`common.port`)} ${e.port}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Nv,{label:`${e.deviceCount} ${t(`common.devices`)}`,size:`small`,variant:`outlined`,color:`default`}),(0,G.jsx)(Nv,{label:`${e.fabricCount} ${t(`common.fabrics`)}`,size:`small`,variant:`outlined`,color:`default`}),e.failedEntityCount>0&&(0,G.jsx)(Nv,{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)(vb,{title:(0,G.jsxs)(Z,{sx:{fontSize:`0.75rem`},children:[(0,G.jsxs)(`div`,{children:[`Fabric #`,e.fabricIndex]}),(0,G.jsxs)(`div`,{children:[`Vendor: `,Dx(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)(Nv,{icon:(0,G.jsx)(Uce,{fabric:e}),label:e.label||Dx(e.rootVendorId),size:`small`,variant:`outlined`})},e.fabricIndex))})]}),(()=>{let n=(e.entityDiagnostics??[]).filter(e=>e.status===`failed`);return n.length>0?(0,G.jsxs)(Wh,{severity:`error`,sx:{mt:1,flexShrink:0,py:0},children:[(0,G.jsxs)(Q,{variant:`caption`,component:`div`,children:[t(`health.failedDevicesTitle`,`Devices that failed to start:`),` `,`(`,n.length,`)`]}),(0,G.jsx)(Z,{sx:{maxHeight:160,overflowY:`auto`},children:n.map(e=>(0,G.jsxs)(Q,{variant:`caption`,component:`div`,color:`text.secondary`,children:[e.entityId,e.reason?`: ${e.reason}`:``,e.failedAt?` (${hx(e.failedAt)})`:``]},e.entityId))})]}):null})(),e.controllerWarnings&&e.controllerWarnings.length>0&&(0,G.jsxs)(Wh,{severity:`warning`,sx:{mt:1,flexShrink:0,py:0},children:[(0,G.jsxs)(Q,{variant:`caption`,component:`div`,children:[t(`health.controllerWarningsTitle`,`Some devices may not show up in a connected controller:`),` `,`(`,e.controllerWarnings.length,`)`]}),(0,G.jsx)(Z,{sx:{maxHeight:160,overflowY:`auto`},children:e.controllerWarnings.map(e=>(0,G.jsxs)(Q,{variant:`caption`,component:`div`,color:`text.secondary`,children:[e.entityId,` on `,e.controllerLabel,e.note?` (${e.note})`:``]},`${e.entityId}:${e.deviceTypeId}:${e.controller}`))})]})]})})},e.id))}),n.recovery.enabled&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,mb:1,children:[(0,G.jsx)(JT,{}),(0,G.jsx)(Q,{variant:`h6`,children:t(`health.autoRecovery`)}),(0,G.jsx)(Nv,{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()}`]}),n.recovery.history&&n.recovery.history.length>0&&(0,G.jsx)(Z,{sx:{mt:1},children:[...n.recovery.history].reverse().map((e,t)=>(0,G.jsxs)(Q,{variant:`caption`,component:`div`,color:`text.secondary`,children:[hx(e.timestamp),`: `,e.bridgeName,` (`,e.outcome,`)`]},`${e.timestamp}:${e.bridgeId}:${t}`))})]}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsx)(r4,{})]})}var i4=e=>e===`pass`?`success`:e===`warn`?`warning`:`error`;function vJe(){let{t:e}=Ts(),[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)(Gm,{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)(xv,{size:`small`,onClick:l,disabled:r,children:r?(0,G.jsx)(zh,{size:16}):e(`health.refresh`)})]}),a&&(0,G.jsx)(Wh,{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)(Nv,{label:`${u} ${e(`health.checksPassed`)}`,color:`success`,size:`small`,variant:`outlined`}),d>0&&(0,G.jsx)(Nv,{label:`${d} ${e(`health.checksWarning`)}`,color:`warning`,size:`small`,variant:`outlined`}),f>0&&(0,G.jsx)(Nv,{label:`${f} ${e(`health.checksFailed`)}`,color:`error`,size:`small`,variant:`outlined`}),(0,G.jsx)(Nv,{label:t.matterConfig.boundInterface?`mDNS: ${t.matterConfig.boundInterface}`:`mDNS: all interfaces`,size:`small`,variant:`outlined`}),(0,G.jsx)(Nv,{label:`IPv4: ${t.matterConfig.ipv4Enabled?`on`:`off`}`,size:`small`,variant:`outlined`})]}),t.checks.filter(e=>e.status!==`pass`).map(e=>(0,G.jsxs)(Wh,{severity:i4(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)(xv,{size:`small`,onClick:()=>c(!s),sx:{mt:.5},children:e(s?`health.hideDetails`:`health.showDetails`)}),(0,G.jsxs)(iy,{in:s,children:[(0,G.jsx)(Q,{variant:`subtitle2`,sx:{mt:1,mb:.5},children:e(`health.allChecks`)}),(0,G.jsxs)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:e(`health.check`)}),(0,G.jsx)(hC,{children:e(`health.statusLabel`)}),(0,G.jsx)(hC,{children:e(`health.message`)})]})}),(0,G.jsx)(mC,{children:t.checks.map(e=>(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:(0,G.jsx)(Q,{variant:`body2`,children:e.name})}),(0,G.jsx)(hC,{children:(0,G.jsx)(Nv,{label:e.status,color:i4(e.status),size:`small`})}),(0,G.jsxs)(hC,{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)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:e(`health.interfaceName`)}),(0,G.jsx)(hC,{children:`IPv4`}),(0,G.jsx)(hC,{children:`IPv6`}),(0,G.jsx)(hC,{children:`MAC`})]})}),(0,G.jsx)(mC,{children:t.interfaces.filter(e=>!e.internal).map(e=>(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{children:e.name}),(0,G.jsx)(hC,{children:e.ipv4.join(`, `)||`-`}),(0,G.jsx)(hC,{children:(0,G.jsx)(Q,{variant:`body2`,sx:{wordBreak:`break-all`,maxWidth:240},children:e.ipv6.join(`, `)||`-`})}),(0,G.jsx)(hC,{children:e.mac})]},e.name))})]})]})]})]})}var a4=`hamh-translation-overrides`;function o4(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,o4(i,e)):n[e]=String(i??``)}return n}function s4(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 c4(e){try{let t=localStorage.getItem(a4);return t?JSON.parse(t)[e]??{}:{}}catch{return{}}}function l4(e,t){try{let n=localStorage.getItem(a4),r=n?JSON.parse(n):{};Object.keys(t).length===0?delete r[e]:r[e]=t,localStorage.setItem(a4,JSON.stringify(r))}catch{}}var u4=`hamh-custom-languages`;function yJe(){try{let e=localStorage.getItem(u4);return e?JSON.parse(e):[]}catch{return[]}}function d4(e){localStorage.setItem(u4,JSON.stringify(e))}var f4=[{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 bJe(){let{t:e,i18n:t}=Ts(),n=t.language??`en`,r=f4.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)(()=>c4(i)),[u,d]=(0,C.useState)(!1),[f,p]=(0,C.useState)(`all`),[m,h]=(0,C.useState)(yJe),[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)(()=>[...f4,...m],[m]),O=(0,C.useCallback)(e=>m.some(t=>t.code===e),[m]),k=(0,C.useMemo)(()=>o4(Ds),[]),A=(0,C.useMemo)(()=>{let e=t.getResourceBundle(i,`translation`);return e?o4(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(c4(i))},[i]);let R=(0,C.useCallback)(e=>{l(e),l4(i,e);let n=t.getResourceBundle(i,`translation`),r=n?o4(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=s4({...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=s4(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=s4(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(f4.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),d4(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),d4(e),l4(i,{}),a(f4[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=o4(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)(mge,{}),(0,G.jsx)(Q,{variant:`h5`,children:e(`translationEditor.title`)})]}),(0,G.jsxs)(Z,{display:`flex`,alignItems:`center`,gap:1,children:[(0,G.jsxs)(Iv,{size:`small`,sx:{minWidth:140},children:[(0,G.jsx)(Ux,{children:e(`translationEditor.editLanguage`)}),(0,G.jsx)(wS,{value:i,label:e(`translationEditor.editLanguage`),onChange:e=>a(e.target.value),children:D.map(e=>(0,G.jsxs)(TS,{value:e.code,children:[(0,G.jsx)(py,{primary:e.name}),O(e.code)&&(0,G.jsx)(dy,{sx:{minWidth:`auto`,ml:1},children:(0,G.jsx)(eE,{fontSize:`small`,color:`disabled`})})]},e.code))})]}),(0,G.jsx)(vb,{title:e(`translationEditor.addLanguage`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>_(e=>!e),children:(0,G.jsx)(yb,{fontSize:`small`})})}),O(i)&&(0,G.jsx)(vb,{title:e(`translationEditor.removeLanguage`),children:(0,G.jsx)(Vh,{size:`small`,color:`error`,onClick:re,children:(0,G.jsx)(eE,{fontSize:`small`})})})]})]}),(0,G.jsx)(iy,{in:g,children:(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:2,alignItems:`flex-start`,flexWrap:`wrap`,children:[(0,G.jsx)(OS,{size:`small`,label:e(`translationEditor.newLanguageCode`),value:v,onChange:e=>y(e.target.value),error:!!S,sx:{width:180}}),(0,G.jsx)(OS,{size:`small`,label:e(`translationEditor.newLanguageName`),value:b,onChange:e=>x(e.target.value),sx:{width:220}}),(0,G.jsx)(xv,{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)(Wh,{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)(Jv,{variant:`determinate`,value:L,sx:{height:8,borderRadius:4}})]}),I>0&&(0,G.jsx)(Nv,{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)(OS,{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)(tF,{position:`start`,children:(0,G.jsx)(gE,{fontSize:`small`})})}}}),(0,G.jsx)(Iv,{size:`small`,sx:{minWidth:130},children:(0,G.jsxs)(wS,{value:f,onChange:e=>p(e.target.value),children:[(0,G.jsx)(TS,{value:`all`,children:e(`translationEditor.filterAll`)}),(0,G.jsx)(TS,{value:`missing`,children:e(`translationEditor.filterMissing`)}),(0,G.jsx)(TS,{value:`edited`,children:e(`translationEditor.filterEdited`)})]})})]}),(0,G.jsxs)(Z,{display:`flex`,gap:1,mb:3,flexWrap:`wrap`,children:[(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(CE,{}),onClick:B,children:e(`translationEditor.exportJson`)}),(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(jT,{}),onClick:ie,children:e(`translationEditor.importJson`)}),(0,G.jsx)(vb,{title:u?e(`translationEditor.copied`):``,children:(0,G.jsx)(xv,{variant:`outlined`,size:`small`,startIcon:(0,G.jsx)(bb,{}),onClick:V,children:e(`translationEditor.copyJson`)})}),I>0&&(0,G.jsx)(xv,{variant:`outlined`,size:`small`,color:`warning`,startIcon:(0,G.jsx)(mE,{}),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)(Xb,{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)(OS,{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)(vb,{title:e(`translationEditor.resetKey`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>z(t.key),children:(0,G.jsx)(mE,{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)(eg,{open:!!T,autoHideDuration:3e3,onClose:()=>E(``),message:T})]})}var p4=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]}`},m4=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`},xJe=()=>{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)(Sv,{children:(0,G.jsx)(Tv,{children:(0,G.jsx)(Q,{children:`Loading system information...`})})});if(!e)return(0,G.jsx)(Sv,{children:(0,G.jsx)(Tv,{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)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Q,{variant:`h6`,gutterBottom:!0,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(Vhe,{}),`System Information`]}),(0,G.jsxs)(Hv,{container:!0,spacing:3,children:[(0,G.jsx)(Hv,{size:{xs:12,md:6},children:(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`Application`}),(0,G.jsxs)(Yv,{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)(Nv,{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)(Nv,{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:m4(e.process.uptime)})]})]})]}),(0,G.jsxs)(Z,{children:[(0,G.jsx)(Q,{variant:`subtitle2`,color:`text.secondary`,children:`System`}),(0,G.jsxs)(Yv,{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:m4(e.uptime)})]})]})]})]})}),(0,G.jsx)(Hv,{size:{xs:12,md:6},children:(0,G.jsxs)(Yv,{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)(cE,{}),`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:[p4(e.memory.used),` /`,` `,p4(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)(cE,{}),`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: `,p4(e.process.rss)]}),(0,G.jsxs)(Q,{variant:`body2`,color:`text.secondary`,children:[`Heap: `,p4(e.process.heapUsed),` /`,` `,p4(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)(dge,{}),`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:[p4(e.storage.used),` /`,` `,p4(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)(Hv,{size:{xs:12},children:[(0,G.jsxs)(Q,{variant:`subtitle2`,color:`text.secondary`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(rge,{}),`Network Interfaces`]}),(0,G.jsx)(Yv,{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)(Nv,{label:`${e.address} (${e.family})`,size:`small`,variant:`outlined`})]},`${e.name}-${e.address}`))})]})]})]})})},SJe=200;function CJe(){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>SJe?n.slice(-200):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 h4(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 g4={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`},_4={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 wJe(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 v4=Object.keys(g4);function TJe({sortField:e,sortDirection:t}={}){let{t:n}=Ts(),r=wm(),{events:i,snapshot:a,connected:o,clearEvents:s}=CJe(),[c,l]=(0,C.useState)(new Set(v4)),[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)(Sv,{children:(0,G.jsxs)(Tv,{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)(pge,{}),(0,G.jsx)(Q,{variant:`h6`,children:n(`diagnostics.title`)}),(0,G.jsx)(Nv,{icon:(0,G.jsx)(qhe,{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)(Yv,{direction:`row`,spacing:.5,alignItems:`center`,children:[(0,G.jsx)(vb,{title:n(`diagnostics.filterEvents`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>d(e=>!e),color:u?`primary`:`default`,children:(0,G.jsx)(wb,{})})}),(0,G.jsx)(vb,{title:n(`diagnostics.clearEvents`),children:(0,G.jsx)(Vh,{size:`small`,onClick:s,children:(0,G.jsx)(zhe,{})})})]})]}),(0,G.jsxs)(Yv,{direction:`row`,spacing:.5,flexWrap:`wrap`,sx:{mb:2,gap:.5},children:[v4.map(e=>{let t=h[e]??0;if(t===0&&!u)return null;let r=g4[e];return(0,G.jsx)(Nv,{label:`${n(_4[e])}: ${t}`,size:`small`,sx:{bgcolor:c.has(e)?r:`action.disabledBackground`,color:c.has(e)?h4(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)(Nv,{label:`Total: ${a.system.eventCount}`,size:`small`,variant:`outlined`,sx:{fontSize:`0.7rem`,height:22}})]}),(0,G.jsx)(iy,{in:u,children:(0,G.jsx)(Gm,{variant:`outlined`,sx:{p:1.5,mb:2},children:(0,G.jsx)(Hv,{container:!0,spacing:0,children:v4.map(e=>{let t=g4[e];return(0,G.jsx)(Hv,{size:{xs:6,sm:4,md:3},children:(0,G.jsx)(Vv,{control:(0,G.jsx)(Av,{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(_4[e])})})},e)})})})}),m.length>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Hv,{container:!0,spacing:1,sx:{mb:2},children:m.map(e=>(0,G.jsx)(EJe,{bridge:e},e.bridgeId))}),(0,G.jsx)(Xb,{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=g4[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:wJe(e.timestamp)}),(0,G.jsx)(Nv,{label:_4[e.type]?n(_4[e.type]):e.type,size:`small`,sx:{bgcolor:t??`#757575`,color:h4(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 EJe({bridge:e}){let[t,n]=(0,C.useState)(!1);return(0,G.jsx)(Hv,{size:{xs:12,sm:6},children:(0,G.jsxs)(Gm,{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)(Yv,{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)(Nv,{label:e.replace(/^auto/,``).replace(/([A-Z])/g,` $1`).trim(),size:`small`,variant:`outlined`,sx:{fontSize:`0.6rem`,height:18}},e)),(0,G.jsx)(Nv,{label:e.status,size:`small`,color:e.status===`running`?`success`:e.status===`failed`?`error`:`default`,sx:{height:20}}),(0,G.jsx)(eC,{sx:{transform:t?`rotate(180deg)`:`rotate(0deg)`,transition:`transform 0.2s`,fontSize:18,color:`text.secondary`}})]})]}),(0,G.jsx)(iy,{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)(Nv,{label:e,size:`small`,variant:`outlined`,sx:{fontSize:`0.58rem`,height:16,"& .MuiChip-label":{px:.5}}},e))})]},e.entityId))})})]})})}var DJe=()=>{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)(_Je,{sortField:e,sortDirection:n,onSortFieldChange:t,onSortDirectionChange:r}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(TJe,{sortField:e,sortDirection:n})}),(0,G.jsx)(Z,{sx:{px:2},children:(0,G.jsx)(vJe,{})}),(0,G.jsx)(Z,{sx:{px:2,pb:2},children:(0,G.jsx)(xJe,{})}),(0,G.jsx)(Xb,{}),(0,G.jsx)(bJe,{})]})};async function OJe(){let e=await fetch(`api/matter/labels?_s=${Date.now()}`);return await z_(e,`Failed to fetch labels`),R_(e)}async function kJe(){let e=await fetch(`api/matter/areas?_s=${Date.now()}`);return await z_(e,`Failed to fetch areas`),R_(e)}async function AJe(){let e=await fetch(`api/matter/filter-values?_s=${Date.now()}`);return await z_(e,`Failed to fetch filter values`),R_(e)}var y4=({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)(OS,{size:`small`,fullWidth:!0,placeholder:`Search...`,value:i,onChange:e=>a(e.target.value),slotProps:{input:{startAdornment:(0,G.jsx)(tF,{position:`start`,children:(0,G.jsx)(gE,{fontSize:`small`})})}}})}),(0,G.jsxs)(Z,{sx:{p:1.5,display:`flex`,flexWrap:`wrap`,gap:.75},children:[o.map(e=>(0,G.jsx)(Nv,{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,`"`]})]})]})},jJe=()=>{let{t:e}=Ts(),[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([OJe(),kJe(),AJe()]);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)(zh,{})}):(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,sx:{mb:3},children:[(0,G.jsx)(wb,{sx:{mr:1,verticalAlign:`middle`}}),e(`labels.title`)]}),(0,G.jsx)(Wh,{severity:`info`,sx:{mb:3},children:e(`labels.info`)}),l&&(0,G.jsx)(Wh,{severity:`error`,sx:{mb:2},children:l}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)(oE,{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)(Sv,{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)(gC,{children:(0,G.jsxs)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.labelId`)}),(0,G.jsx)(hC,{width:48})]})}),(0,G.jsx)(mC,{children:t.map(t=>(0,G.jsxs)(xC,{hover:!0,children:[(0,G.jsxs)(hC,{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)(hC,{children:(0,G.jsx)(`code`,{children:t.label_id})}),(0,G.jsx)(hC,{children:(0,G.jsx)(vb,{title:d===t.label_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>m(t.label_id),children:(0,G.jsx)(bb,{fontSize:`small`})})})})]},t.label_id))})]})})}),(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:1},children:[(0,G.jsx)(wT,{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)(Sv,{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)(gC,{children:(0,G.jsxs)(dC,{size:`small`,children:[(0,G.jsx)(vC,{children:(0,G.jsxs)(xC,{children:[(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.displayName`)}),(0,G.jsx)(hC,{sx:{fontWeight:`bold`},children:e(`labels.areaId`)}),(0,G.jsx)(hC,{width:48})]})}),(0,G.jsx)(mC,{children:r.map(t=>(0,G.jsxs)(xC,{hover:!0,children:[(0,G.jsx)(hC,{children:t.name}),(0,G.jsx)(hC,{children:(0,G.jsx)(`code`,{children:t.area_id})}),(0,G.jsx)(hC,{children:(0,G.jsx)(vb,{title:d===t.area_id?e(`common.copied`):e(`common.copyId`),children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>m(t.area_id),children:(0,G.jsx)(bb,{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)(aC,{defaultExpanded:!0,children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(_ge,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.domains`),` (`,a.domains.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.domains,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(nE,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.platforms`),` (`,a.platforms.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.platforms,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(ZT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.entityCategories`),` (`,a.entityCategories.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.entityCategories,copiedId:d,onCopy:m})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(ZT,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceClasses`),` (`,a.deviceClasses.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.deviceClasses,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(xb,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.deviceNames`),` (`,a.deviceNames.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.deviceNames,copiedId:d,onCopy:m,searchable:!0})]})]}),(0,G.jsxs)(aC,{children:[(0,G.jsxs)(cC,{expandIcon:(0,G.jsx)(eC,{}),children:[(0,G.jsx)(xb,{sx:{mr:1}}),(0,G.jsxs)(Q,{children:[e(`labels.productNames`),` (`,a.productNames.length,`)`]})]}),(0,G.jsxs)(oC,{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)(y4,{values:a.productNames,copiedId:d,onCopy:m,searchable:!0})]})]})]})]})};async function MJe(){let e=await fetch(`api/lock-credentials`);return await z_(e,`Failed to fetch lock credentials`),R_(e)}async function NJe(e,t){let n=await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return await z_(n,`Failed to update lock credential`),R_(n)}async function PJe(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 z_(n,`Failed to toggle credential`),R_(n)}async function FJe(e){await z_(await fetch(`api/lock-credentials/${encodeURIComponent(e)}`,{method:`DELETE`}),`Failed to delete lock credential`)}var IJe=({open:e,onClose:t,onSave:n,initialEntityId:r=``,initialName:i=``,isEdit:a=!1})=>{let{t:o}=Ts(),[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)(Gb,{open:e,onClose:t,maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Jb,{children:o(a?`lockCredentials.editCredential`:`lockCredentials.addCredential`)}),(0,G.jsx)(qb,{children:(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,mt:1},children:[p&&(0,G.jsx)(Wh,{severity:`error`,children:p}),(0,G.jsx)(OS,{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)(OS,{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)(OS,{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)(Kb,{children:[(0,G.jsx)(xv,{onClick:t,disabled:h,children:o(`common.cancel`)}),(0,G.jsx)(xv,{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)(zh,{size:16}):(0,G.jsx)(hE,{}),children:o(`common.save`)})]})]})},LJe=()=>{let{t:e}=Ts(),[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 MJe()).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 NJe(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 FJe(t),await d()}catch(t){o(t instanceof Error?t.message:e(`lockCredentials.deleteFailed`))}},g=async t=>{try{await PJe(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)(CT,{sx:{mr:1,verticalAlign:`middle`}}),e(`lockCredentials.title`)]}),(0,G.jsx)(xv,{variant:`contained`,startIcon:(0,G.jsx)(yb,{}),onClick:v,children:e(`lockCredentials.addCredential`)})]}),(0,G.jsx)(Wh,{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)(Wh,{severity:`error`,sx:{mb:2},children:a}),r?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(zh,{})}):t.length===0?(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{sx:{textAlign:`center`,py:4},children:[(0,G.jsx)(CT,{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)(xv,{variant:`outlined`,startIcon:(0,G.jsx)(yb,{}),onClick:v,children:`Add Your First Credential`})]})}):(0,G.jsx)(Sv,{children:(0,G.jsx)(oy,{children:t.map((n,r)=>(0,G.jsxs)(ly,{divider:r<t.length-1,onClick:()=>_(n),sx:{cursor:`pointer`,"&:hover":{bgcolor:`action.hover`}},children:[(0,G.jsx)(dy,{children:(0,G.jsx)(CT,{color:n.enabled?`primary`:`disabled`})}),(0,G.jsx)(py,{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)(cy,{children:[(0,G.jsx)(vb,{title:n.enabled?e(`lockCredentials.disable`):e(`lockCredentials.enable`),children:(0,G.jsx)(qS,{edge:`end`,checked:n.enabled,onChange:e=>{e.stopPropagation(),g(n)}})}),(0,G.jsx)(vb,{title:e(`common.delete`),children:(0,G.jsx)(Vh,{edge:`end`,onClick:e=>{e.stopPropagation(),m(n.entityId)},sx:{ml:1},children:(0,G.jsx)(RS,{})})})]})]},n.entityId))})}),(0,G.jsx)(IJe,{open:s,onClose:()=>c(!1),onSave:f,initialEntityId:l?.entityId,initialName:l?.name,isEdit:!!l}),(0,G.jsx)(VT,{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)})]})},RJe=()=>{let e=Pr(),{t}=Ts();return(0,G.jsxs)(Z,{display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,minHeight:`60vh`,gap:2,p:4,children:[(0,G.jsx)(lge,{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)(xv,{variant:`contained`,startIcon:(0,G.jsx)(iE,{}),onClick:()=>e(Y9.dashboard),children:t(`notFound.backToDashboard`)})]})};function b4(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=b4(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var zJe={value:()=>{}};function x4(){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 S4(n)}function S4(e){this._=e}function BJe(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}})}S4.prototype=x4.prototype={constructor:S4,on:function(e,t){var n=this._,r=BJe(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=VJe(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]=C4(n[i],e.name,t);else if(t==null)for(i in n)n[i]=C4(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 S4(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 VJe(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function C4(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=zJe,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var w4={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 T4(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),w4.hasOwnProperty(t)?{space:w4[t],local:e}:e}function HJe(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 UJe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function E4(e){var t=T4(e);return(t.local?UJe:HJe)(t)}function WJe(){}function D4(e){return e==null?WJe:function(){return this.querySelector(e)}}function GJe(e){typeof e!=`function`&&(e=D4(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 H4(r,this._parents)}function KJe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function qJe(){return[]}function O4(e){return e==null?qJe:function(){return this.querySelectorAll(e)}}function JJe(e){return function(){return KJe(e.apply(this,arguments))}}function YJe(e){e=typeof e==`function`?JJe(e):O4(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 H4(r,i)}function k4(e){return function(){return this.matches(e)}}function A4(e){return function(t){return t.matches(e)}}var XJe=Array.prototype.find;function ZJe(e){return function(){return XJe.call(this.children,e)}}function QJe(){return this.firstElementChild}function $Je(e){return this.select(e==null?QJe:ZJe(typeof e==`function`?e:A4(e)))}var eYe=Array.prototype.filter;function tYe(){return Array.from(this.children)}function nYe(e){return function(){return eYe.call(this.children,e)}}function rYe(e){return this.selectAll(e==null?tYe:nYe(typeof e==`function`?e:A4(e)))}function iYe(e){typeof e!=`function`&&(e=k4(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 H4(r,this._parents)}function j4(e){return Array(e.length)}function aYe(){return new H4(this._enter||this._groups.map(j4),this._parents)}function M4(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}M4.prototype={constructor:M4,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 oYe(e){return function(){return e}}function sYe(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 M4(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function cYe(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 M4(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function lYe(e){return e.__data__}function uYe(e,t){if(!arguments.length)return Array.from(this,lYe);var n=t?cYe:sYe,r=this._parents,i=this._groups;typeof e!=`function`&&(e=oYe(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=dYe(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 H4(o,r),o._enter=s,o._exit=c,o}function dYe(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function fYe(){return new H4(this._exit||this._groups.map(j4),this._parents)}function pYe(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 mYe(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 H4(s,this._parents)}function hYe(){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 gYe(e){e||=_Ye;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 H4(i,this._parents).order()}function _Ye(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function vYe(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function yYe(){return Array.from(this)}function bYe(){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 xYe(){let e=0;for(let t of this)++e;return e}function SYe(){return!this.node()}function CYe(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 wYe(e){return function(){this.removeAttribute(e)}}function TYe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function EYe(e,t){return function(){this.setAttribute(e,t)}}function DYe(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function OYe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function kYe(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 AYe(e,t){var n=T4(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?TYe:wYe:typeof t==`function`?n.local?kYe:OYe:n.local?DYe:EYe)(n,t))}function N4(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function jYe(e){return function(){this.style.removeProperty(e)}}function MYe(e,t,n){return function(){this.style.setProperty(e,t,n)}}function NYe(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function PYe(e,t,n){return arguments.length>1?this.each((t==null?jYe:typeof t==`function`?NYe:MYe)(e,t,n??``)):P4(this.node(),e)}function P4(e,t){return e.style.getPropertyValue(t)||N4(e).getComputedStyle(e,null).getPropertyValue(t)}function FYe(e){return function(){delete this[e]}}function IYe(e,t){return function(){this[e]=t}}function LYe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function RYe(e,t){return arguments.length>1?this.each((t==null?FYe:typeof t==`function`?LYe:IYe)(e,t)):this.node()[e]}function F4(e){return e.trim().split(/^|\s+/)}function I4(e){return e.classList||new L4(e)}function L4(e){this._node=e,this._names=F4(e.getAttribute(`class`)||``)}L4.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 R4(e,t){for(var n=I4(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function z4(e,t){for(var n=I4(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function zYe(e){return function(){R4(this,e)}}function BYe(e){return function(){z4(this,e)}}function VYe(e,t){return function(){(t.apply(this,arguments)?R4:z4)(this,e)}}function HYe(e,t){var n=F4(e+``);if(arguments.length<2){for(var r=I4(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?VYe:t?zYe:BYe)(n,t))}function UYe(){this.textContent=``}function WYe(e){return function(){this.textContent=e}}function GYe(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function KYe(e){return arguments.length?this.each(e==null?UYe:(typeof e==`function`?GYe:WYe)(e)):this.node().textContent}function qYe(){this.innerHTML=``}function JYe(e){return function(){this.innerHTML=e}}function YYe(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function XYe(e){return arguments.length?this.each(e==null?qYe:(typeof e==`function`?YYe:JYe)(e)):this.node().innerHTML}function ZYe(){this.nextSibling&&this.parentNode.appendChild(this)}function QYe(){return this.each(ZYe)}function $Ye(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function eXe(){return this.each($Ye)}function tXe(e){var t=typeof e==`function`?e:E4(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function nXe(){return null}function rXe(e,t){var n=typeof e==`function`?e:E4(e),r=t==null?nXe:typeof t==`function`?t:D4(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function iXe(){var e=this.parentNode;e&&e.removeChild(this)}function aXe(){return this.each(iXe)}function oXe(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function sXe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cXe(e){return this.select(e?sXe:oXe)}function lXe(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function uXe(e){return function(t){e.call(this,t,this.__data__)}}function dXe(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 fXe(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 pXe(e,t,n){return function(){var r=this.__on,i,a=uXe(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 mXe(e,t,n){var r=dXe(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?pXe:fXe,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function B4(e,t,n){var r=N4(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 hXe(e,t){return function(){return B4(this,e,t)}}function gXe(e,t){return function(){return B4(this,e,t.apply(this,arguments))}}function _Xe(e,t){return this.each((typeof t==`function`?gXe:hXe)(e,t))}function*vXe(){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 V4=[null];function H4(e,t){this._groups=e,this._parents=t}function U4(){return new H4([[document.documentElement]],V4)}function yXe(){return this}H4.prototype=U4.prototype={constructor:H4,select:GJe,selectAll:YJe,selectChild:$Je,selectChildren:rYe,filter:iYe,data:uYe,enter:aYe,exit:fYe,join:pYe,merge:mYe,selection:yXe,order:hYe,sort:gYe,call:vYe,nodes:yYe,node:bYe,size:xYe,empty:SYe,each:CYe,attr:AYe,style:PYe,property:RYe,classed:HYe,text:KYe,html:XYe,raise:QYe,lower:eXe,append:tXe,insert:rXe,remove:aXe,clone:cXe,datum:lXe,on:mXe,dispatch:_Xe,[Symbol.iterator]:vXe};function W4(e){return typeof e==`string`?new H4([[document.querySelector(e)]],[document.documentElement]):new H4([[e]],V4)}function bXe(e){let t;for(;t=e.sourceEvent;)e=t;return e}function G4(e,t){if(e=bXe(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 xXe={passive:!1},K4={capture:!0,passive:!1};function q4(e){e.stopImmediatePropagation()}function J4(e){e.preventDefault(),e.stopImmediatePropagation()}function Y4(e){var t=e.document.documentElement,n=W4(e).on(`dragstart.drag`,J4,K4);`onselectstart`in t?n.on(`selectstart.drag`,J4,K4):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function X4(e,t){var n=e.document.documentElement,r=W4(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,J4,K4),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 Z4=e=>()=>e;function Q4(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}})}Q4.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function SXe(e){return!e.ctrlKey&&!e.button}function CXe(){return this.parentNode}function wXe(e,t){return t??{x:e.x,y:e.y}}function TXe(){return navigator.maxTouchPoints||`ontouchstart`in this}function $4(){var e=SXe,t=CXe,n=wXe,r=TXe,i={},a=x4(`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`,_,xXe).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&&(W4(n.view).on(`mousemove.drag`,m,K4).on(`mouseup.drag`,h,K4),Y4(n.view),q4(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(J4(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){W4(e.view).on(`mousemove.drag mouseup.drag`,null),X4(e.view,l),J4(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]))&&(q4(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])&&(J4(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])&&(q4(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=G4(l||r,t),p,m,h;if((h=n.call(e,new Q4(`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=G4(l||a,t),_=o;break}u.call(r,e,new Q4(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:Z4(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:Z4(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:Z4(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:Z4(!!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 e3(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function t3(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function n3(){}var r3=.7,i3=1/r3,a3=`\\s*([+-]?\\d+)\\s*`,o3=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,s3=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,EXe=/^#([0-9a-f]{3,8})$/,DXe=RegExp(`^rgb\\(${a3},${a3},${a3}\\)$`),OXe=RegExp(`^rgb\\(${s3},${s3},${s3}\\)$`),kXe=RegExp(`^rgba\\(${a3},${a3},${a3},${o3}\\)$`),AXe=RegExp(`^rgba\\(${s3},${s3},${s3},${o3}\\)$`),jXe=RegExp(`^hsl\\(${o3},${s3},${s3}\\)$`),MXe=RegExp(`^hsla\\(${o3},${s3},${s3},${o3}\\)$`),c3={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};e3(n3,d3,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:l3,formatHex:l3,formatHex8:NXe,formatHsl:PXe,formatRgb:u3,toString:u3});function l3(){return this.rgb().formatHex()}function NXe(){return this.rgb().formatHex8()}function PXe(){return S3(this).formatHsl()}function u3(){return this.rgb().formatRgb()}function d3(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=EXe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?f3(t):n===3?new h3(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?p3(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?p3(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=DXe.exec(e))?new h3(t[1],t[2],t[3],1):(t=OXe.exec(e))?new h3(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=kXe.exec(e))?p3(t[1],t[2],t[3],t[4]):(t=AXe.exec(e))?p3(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=jXe.exec(e))?x3(t[1],t[2]/100,t[3]/100,1):(t=MXe.exec(e))?x3(t[1],t[2]/100,t[3]/100,t[4]):c3.hasOwnProperty(e)?f3(c3[e]):e===`transparent`?new h3(NaN,NaN,NaN,0):null}function f3(e){return new h3(e>>16&255,e>>8&255,e&255,1)}function p3(e,t,n,r){return r<=0&&(e=t=n=NaN),new h3(e,t,n,r)}function FXe(e){return e instanceof n3||(e=d3(e)),e?(e=e.rgb(),new h3(e.r,e.g,e.b,e.opacity)):new h3}function m3(e,t,n,r){return arguments.length===1?FXe(e):new h3(e,t,n,r??1)}function h3(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}e3(h3,m3,t3(n3,{brighter(e){return e=e==null?i3:i3**+e,new h3(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?r3:r3**+e,new h3(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new h3(y3(this.r),y3(this.g),y3(this.b),v3(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:g3,formatHex:g3,formatHex8:IXe,formatRgb:_3,toString:_3}));function g3(){return`#${b3(this.r)}${b3(this.g)}${b3(this.b)}`}function IXe(){return`#${b3(this.r)}${b3(this.g)}${b3(this.b)}${b3((isNaN(this.opacity)?1:this.opacity)*255)}`}function _3(){let e=v3(this.opacity);return`${e===1?`rgb(`:`rgba(`}${y3(this.r)}, ${y3(this.g)}, ${y3(this.b)}${e===1?`)`:`, ${e})`}`}function v3(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function y3(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function b3(e){return e=y3(e),(e<16?`0`:``)+e.toString(16)}function x3(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new C3(e,t,n,r)}function S3(e){if(e instanceof C3)return new C3(e.h,e.s,e.l,e.opacity);if(e instanceof n3||(e=d3(e)),!e)return new C3;if(e instanceof C3)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 C3(o,s,c,e.opacity)}function LXe(e,t,n,r){return arguments.length===1?S3(e):new C3(e,t,n,r??1)}function C3(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}e3(C3,LXe,t3(n3,{brighter(e){return e=e==null?i3:i3**+e,new C3(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?r3:r3**+e,new C3(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 h3(E3(e>=240?e-240:e+120,i,r),E3(e,i,r),E3(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new C3(w3(this.h),T3(this.s),T3(this.l),v3(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=v3(this.opacity);return`${e===1?`hsl(`:`hsla(`}${w3(this.h)}, ${T3(this.s)*100}%, ${T3(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function w3(e){return e=(e||0)%360,e<0?e+360:e}function T3(e){return Math.max(0,Math.min(1,e||0))}function E3(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 D3=e=>()=>e;function RXe(e,t){return function(n){return e+n*t}}function zXe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function BXe(e){return(e=+e)==1?O3:function(t,n){return n-t?zXe(t,n,e):D3(isNaN(t)?n:t)}}function O3(e,t){var n=t-e;return n?RXe(e,n):D3(isNaN(e)?t:e)}var k3=(function e(t){var n=BXe(t);function r(e,t){var r=n((e=m3(e)).r,(t=m3(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=O3(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 VXe(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 HXe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function UXe(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]=P3(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 WXe(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function A3(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function GXe(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]=P3(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var j3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,M3=new RegExp(j3.source,`g`);function KXe(e){return function(){return e}}function qXe(e){return function(t){return e(t)+``}}function N3(e,t){var n=j3.lastIndex=M3.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=j3.exec(e))&&(i=M3.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:A3(r,i)})),n=M3.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?qXe(c[0].x):KXe(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 P3(e,t){var n=typeof t,r;return t==null||n===`boolean`?D3(t):(n===`number`?A3:n===`string`?(r=d3(t))?(t=r,k3):N3:t instanceof d3?k3:t instanceof Date?WXe:HXe(t)?VXe:Array.isArray(t)?UXe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?GXe:A3)(e,t)}var F3=180/Math.PI,I3={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function L3(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)*F3,skewX:Math.atan(c)*F3,scaleX:o,scaleY:s}}var R3;function JXe(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?I3:L3(t.a,t.b,t.c,t.d,t.e,t.f)}function YXe(e){return e==null||(R3||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),R3.setAttribute(`transform`,e),!(e=R3.transform.baseVal.consolidate()))?I3:(e=e.matrix,L3(e.a,e.b,e.c,e.d,e.e,e.f))}function z3(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:A3(e,i)},{i:c-2,x:A3(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:A3(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:A3(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:A3(e,n)},{i:s-2,x:A3(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 XXe=z3(JXe,`px, `,`px)`,`deg)`),ZXe=z3(YXe,`, `,`)`,`)`),QXe=1e-12;function B3(e){return((e=Math.exp(e))+1/e)/2}function $Xe(e){return((e=Math.exp(e))-1/e)/2}function eZe(e){return((e=Math.exp(2*e))-1)/(e+1)}var V3=(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<QXe)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=B3(y),c=s/(n*g)*(i*eZe(t*r+y)-$Xe(y));return[a+c*d,o+c*f,s*i/B3(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),H3=0,U3=0,W3=0,G3=1e3,K3,q3,J3=0,Y3=0,X3=0,Z3=typeof performance==`object`&&performance.now?performance:Date,Q3=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function $3(){return Y3||=(Q3(tZe),Z3.now()+X3)}function tZe(){Y3=0}function e6(){this._call=this._time=this._next=null}e6.prototype=t6.prototype={constructor:e6,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?$3():+n)+(t==null?0:+t),!this._next&&q3!==this&&(q3?q3._next=this:K3=this,q3=this),this._call=e,this._time=n,r6()},stop:function(){this._call&&(this._call=null,this._time=1/0,r6())}};function t6(e,t,n){var r=new e6;return r.restart(e,t,n),r}function nZe(){$3(),++H3;for(var e=K3,t;e;)(t=Y3-e._time)>=0&&e._call.call(void 0,t),e=e._next;--H3}function n6(){Y3=(J3=Z3.now())+X3,H3=U3=0;try{nZe()}finally{H3=0,iZe(),Y3=0}}function rZe(){var e=Z3.now(),t=e-J3;t>G3&&(X3-=t,J3=e)}function iZe(){for(var e,t=K3,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:K3=n);q3=e,r6(r)}function r6(e){H3||(U3&&=clearTimeout(U3),e-Y3>24?(e<1/0&&(U3=setTimeout(n6,e-Z3.now()-X3)),W3&&=clearInterval(W3)):(W3||=(J3=Z3.now(),setInterval(rZe,G3)),H3=1,Q3(n6)))}function i6(e,t,n){var r=new e6;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var aZe=x4(`start`,`end`,`cancel`,`interrupt`),oZe=[];function a6(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;sZe(e,n,{name:t,index:r,group:i,on:aZe,tween:oZe,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function o6(e,t){var n=c6(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function s6(e,t){var n=c6(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function c6(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function sZe(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=t6(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 i6(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(i6(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 l6(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 cZe(e){return this.each(function(){l6(this,e)})}function lZe(e,t){var n,r;return function(){var i=s6(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 uZe(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=s6(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 dZe(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=c6(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?lZe:uZe)(n,e,t))}function u6(e,t,n){var r=e._id;return e.each(function(){var e=s6(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return c6(e,r).value[t]}}function d6(e,t){var n;return(typeof t==`number`?A3:t instanceof d3?k3:(n=d3(t))?(t=n,k3):N3)(e,t)}function fZe(e){return function(){this.removeAttribute(e)}}function pZe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mZe(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 hZe(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 gZe(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 _Ze(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 vZe(e,t){var n=T4(e),r=n===`transform`?ZXe:d6;return this.attrTween(e,typeof t==`function`?(n.local?_Ze:gZe)(n,r,u6(this,`attr.`+e,t)):t==null?(n.local?pZe:fZe)(n):(n.local?hZe:mZe)(n,r,t))}function yZe(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function bZe(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function xZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&bZe(e,i)),n}return i._value=t,i}function SZe(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&yZe(e,i)),n}return i._value=t,i}function CZe(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=T4(e);return this.tween(n,(r.local?xZe:SZe)(r,t))}function wZe(e,t){return function(){o6(this,e).delay=+t.apply(this,arguments)}}function TZe(e,t){return t=+t,function(){o6(this,e).delay=t}}function EZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?wZe:TZe)(t,e)):c6(this.node(),t).delay}function DZe(e,t){return function(){s6(this,e).duration=+t.apply(this,arguments)}}function OZe(e,t){return t=+t,function(){s6(this,e).duration=t}}function kZe(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?DZe:OZe)(t,e)):c6(this.node(),t).duration}function AZe(e,t){if(typeof t!=`function`)throw Error();return function(){s6(this,e).ease=t}}function jZe(e){var t=this._id;return arguments.length?this.each(AZe(t,e)):c6(this.node(),t).ease}function MZe(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();s6(this,e).ease=n}}function NZe(e){if(typeof e!=`function`)throw Error();return this.each(MZe(this._id,e))}function PZe(e){typeof e!=`function`&&(e=k4(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 p6(r,this._parents,this._name,this._id)}function FZe(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 p6(o,this._parents,this._name,this._id)}function IZe(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 LZe(e,t,n){var r,i,a=IZe(t)?o6:s6;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function RZe(e,t){var n=this._id;return arguments.length<2?c6(this.node(),n).on.on(e):this.each(LZe(n,e,t))}function zZe(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function BZe(){return this.on(`end.remove`,zZe(this._id))}function VZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=D4(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,a6(l[f],t,n,f,l,c6(u,n)));return new p6(a,this._parents,t,n)}function HZe(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=O4(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=c6(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&a6(p,t,n,h,f,m);a.push(f),o.push(u)}return new p6(a,o,t,n)}var UZe=U4.prototype.constructor;function WZe(){return new UZe(this._groups,this._parents)}function GZe(e,t){var n,r,i;return function(){var a=P4(this,e),o=(this.style.removeProperty(e),P4(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function f6(e){return function(){this.style.removeProperty(e)}}function KZe(e,t,n){var r,i=n+``,a;return function(){var o=P4(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function qZe(e,t,n){var r,i,a;return function(){var o=P4(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),P4(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function JZe(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=s6(this,e),l=c.on,u=c.value[a]==null?s||=f6(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function YZe(e,t,n){var r=(e+=``)==`transform`?XXe:d6;return t==null?this.styleTween(e,GZe(e,r)).on(`end.style.`+e,f6(e)):typeof t==`function`?this.styleTween(e,qZe(e,r,u6(this,`style.`+e,t))).each(JZe(this._id,e)):this.styleTween(e,KZe(e,r,t),n).on(`end.style.`+e,null)}function XZe(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function ZZe(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&XZe(e,a,n)),r}return a._value=t,a}function QZe(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,ZZe(e,t,n??``))}function $Ze(e){return function(){this.textContent=e}}function eQe(e){return function(){var t=e(this);this.textContent=t??``}}function tQe(e){return this.tween(`text`,typeof e==`function`?eQe(u6(this,`text`,e)):$Ze(e==null?``:e+``))}function nQe(e){return function(t){this.textContent=e.call(this,t)}}function rQe(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&nQe(r)),t}return r._value=e,r}function iQe(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,rQe(e))}function aQe(){for(var e=this._name,t=this._id,n=m6(),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=c6(c,t);a6(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new p6(r,this._parents,e,n)}function oQe(){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=s6(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 sQe=0;function p6(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function cQe(e){return U4().transition(e)}function m6(){return++sQe}var h6=U4.prototype;p6.prototype=cQe.prototype={constructor:p6,select:VZe,selectAll:HZe,selectChild:h6.selectChild,selectChildren:h6.selectChildren,filter:PZe,merge:FZe,selection:WZe,transition:aQe,call:h6.call,nodes:h6.nodes,node:h6.node,size:h6.size,empty:h6.empty,each:h6.each,on:RZe,attr:vZe,attrTween:CZe,style:YZe,styleTween:QZe,text:tQe,textTween:iQe,remove:BZe,tween:dZe,delay:EZe,duration:kZe,ease:jZe,easeVarying:NZe,end:oQe,[Symbol.iterator]:h6[Symbol.iterator]};function lQe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var uQe={time:null,delay:0,duration:250,ease:lQe};function dQe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function fQe(e){var t,n;e instanceof p6?(t=e._id,e=e._name):(t=m6(),(n=uQe).time=$3(),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])&&a6(c,e,t,l,o,n||dQe(c,t));return new p6(r,this._parents,e,t)}U4.prototype.interrupt=cZe,U4.prototype.transition=fQe;var g6=e=>()=>e;function pQe(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 _6(e,t,n){this.k=e,this.x=t,this.y=n}_6.prototype={constructor:_6,scale:function(e){return e===1?this:new _6(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _6(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 v6=new _6(1,0,0);y6.prototype=_6.prototype;function y6(e){for(;!e.__zoom;)if(!(e=e.parentNode))return v6;return e.__zoom}function b6(e){e.stopImmediatePropagation()}function x6(e){e.preventDefault(),e.stopImmediatePropagation()}function mQe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function hQe(){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 S6(){return this.__zoom||v6}function gQe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function _Qe(){return navigator.maxTouchPoints||`ontouchstart`in this}function vQe(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 C6(){var e=mQe,t=hQe,n=vQe,r=gQe,i=_Qe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=V3,l=x4(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,S6).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`,S6),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(v6.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 _6(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 _6(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 _6(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=W4(this.that).datum();l.call(e,this.that,new pQe(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=G4(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)],l6(this),s.start();x6(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=W4(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=G4(t,i),l=t.clientX,u=t.clientY;Y4(t.view),b6(t),a.mouse=[c,this.__zoom.invert(c)],l6(this),a.start();function d(e){if(x6(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]=G4(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),X4(e.view,a.moved),x6(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=G4(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);x6(r),s>0?W4(this).transition().duration(s).call(x,d,c,r):W4(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(b6(t),s=0;s<i;++s)c=r[s],l=G4(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)),l6(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(x6(e),s=0;s<a;++s)c=i[s],l=G4(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(b6(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=G4(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=W4(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:g6(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:g6(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:g6(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:g6([[+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 w6={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.`},T6=[[-1/0,-1/0],[1/0,1/0]],E6=[`Enter`,` `,`Escape`],D6={"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`},O6;(function(e){e.Strict=`strict`,e.Loose=`loose`})(O6||={});var k6;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(k6||={});var A6;(function(e){e.Partial=`partial`,e.Full=`full`})(A6||={});var j6={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},M6;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(M6||={});var N6;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(N6||={});var P6;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(P6||={});var F6={[P6.Left]:P6.Right,[P6.Right]:P6.Left,[P6.Top]:P6.Bottom,[P6.Bottom]:P6.Top};function I6(e){return e===null?null:e?`valid`:`invalid`}var L6=e=>`id`in e&&`source`in e&&`target`in e,yQe=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),R6=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),z6=(e,t=[0,0])=>{let{width:n,height:r}=u8(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},bQe=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:X6(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):R6(n)?n:t.nodeLookup.get(n.id)),J6(e,i?Q6(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),B6=(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=J6(n,Q6(e)),r=!0)}),r?X6(n):{x:0,y:0,width:0,height:0}},V6=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...i8(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=e8(s,Z6(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},xQe=(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 SQe(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 CQe({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=s8(B6(SQe(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 H6({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`,w6.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&l8(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=l8(d)?W6(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,w6.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 wQe({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=xQe(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 U6=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),W6=(e={x:0,y:0},t,n)=>({x:U6(e.x,t[0][0],t[1][0]-(n?.width??0)),y:U6(e.y,t[0][1],t[1][1]-(n?.height??0))});function G6(e,t,n){let{width:r,height:i}=u8(n),{x:a,y:o}=n.internals.positionAbsolute;return W6(e,[[a,o],[a+r,o+i]],t)}var K6=(e,t,n)=>e<t?U6(Math.abs(e-t),1,t)/t:e>n?-U6(Math.abs(e-n),1,t)/t:0,q6=(e,t,n=15,r=40)=>[K6(e.x,r,t.width-r)*n,K6(e.y,r,t.height-r)*n],J6=(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)}),Y6=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),X6=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Z6=(e,t=[0,0])=>{let{x:n,y:r}=R6(e)?e.internals.positionAbsolute:z6(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}},Q6=(e,t=[0,0])=>{let{x:n,y:r}=R6(e)?e.internals.positionAbsolute:z6(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)}},$6=(e,t)=>X6(J6(Y6(e),Y6(t))),e8=(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)},t8=e=>n8(e.width)&&n8(e.height)&&n8(e.x)&&n8(e.y),n8=e=>!isNaN(e)&&isFinite(e),TQe=(e,t)=>{},r8=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),i8=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?r8(s,o):s},a8=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function o8(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 EQe(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=o8(e,n),i=o8(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=o8(e.top??e.y??0,n),i=o8(e.bottom??e.y??0,n),a=o8(e.left??e.x??0,t),o=o8(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 DQe(e,t,n,r,i,a){let{x:o,y:s}=a8(e,[t,n,r]),{x:c,y:l}=a8({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 s8=(e,t,n,r,i,a)=>{let o=EQe(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=U6(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=DQe(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}},c8=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function l8(e){return e!=null&&e!==`parent`}function u8(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function d8(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function f8(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 p8(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function OQe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function kQe(e){return{...D6,...e||{}}}function m8(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=y8(e),s=i8({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?r8(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var h8=e=>({width:e.offsetWidth,height:e.offsetHeight}),g8=e=>e?.getRootNode?.()||window?.document,AQe=[`INPUT`,`SELECT`,`TEXTAREA`];function _8(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?AQe.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var v8=e=>`clientX`in e,y8=(e,t)=>{let n=v8(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)}},b8=(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,...h8(t)}})};function x8({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 S8(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function C8({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case P6.Left:return[t-S8(t-r,a),n];case P6.Right:return[t+S8(r-t,a),n];case P6.Top:return[t,n-S8(n-i,a)];case P6.Bottom:return[t,n+S8(i-n,a)]}}function w8({sourceX:e,sourceY:t,sourcePosition:n=P6.Bottom,targetX:r,targetY:i,targetPosition:a=P6.Top,curvature:o=.25}){let[s,c]=C8({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=C8({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=x8({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 T8({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 jQe({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 MQe({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=J6(Q6(e),Q6(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),e8({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},X6(a))>0}var NQe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,PQe=(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)),FQe=(e,t,n={})=>{if(!e.source||!e.target)return w6.error006(),t;let r=n.getEdgeId||NQe,i;return i=L6(e)?{...e}:{...e,id:r(e)},PQe(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function E8({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=T8({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var D8={[P6.Left]:{x:-1,y:0},[P6.Right]:{x:1,y:0},[P6.Top]:{x:0,y:-1},[P6.Bottom]:{x:0,y:1}},IQe=({source:e,sourcePosition:t=P6.Bottom,target:n})=>t===P6.Left||t===P6.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},O8=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function LQe({source:e,sourcePosition:t=P6.Bottom,target:n,targetPosition:r=P6.Top,center:i,offset:a,stepPosition:o}){let s=D8[t],c=D8[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=IQe({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]=T8({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 RQe(e,t,n,r){let i=Math.min(O8(e,t)/2,O8(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 k8({sourceX:e,sourceY:t,sourcePosition:n=P6.Bottom,targetX:r,targetY:i,targetPosition:a=P6.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=LQe({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+=RQe(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 A8(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zQe(e){let{sourceNode:t,targetNode:n}=e;if(!A8(t)||!A8(n))return null;let r=t.internals.handleBounds||j8(t.handles),i=n.internals.handleBounds||j8(n.handles),a=N8(r?.source??[],e.sourceHandle),o=N8(e.connectionMode===O6.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,w6.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||P6.Bottom,c=o?.position||P6.Top,l=M8(t,a,s),u=M8(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function j8(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 M8(e,t,n=P6.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??u8(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case P6.Top:return{x:i+o/2,y:a};case P6.Right:return{x:i+o,y:a+s/2};case P6.Bottom:return{x:i+o/2,y:a+s};case P6.Left:return{x:i,y:a+s/2}}}function N8(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function P8(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function BQe(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=P8(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 F8=1e3,VQe=10,I8={nodeOrigin:[0,0],nodeExtent:T6,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},HQe={...I8,checkEquality:!0};function L8(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function UQe(e,t,n){let r=L8(I8,n);for(let n of e.values())if(n.parentId)B8(n,e,t,r);else{let e=W6(z6(n,r.nodeOrigin),l8(n.extent)?n.extent:r.nodeExtent,u8(n));n.internals.positionAbsolute=e}}function WQe(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 R8(e){return e===`manual`}function z8(e,t,n,r={}){let i=L8(HQe,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!R8(i.zIndexMode)?F8: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=W6(z6(u,i.nodeOrigin),l8(u.extent)?u.extent:i.nodeExtent,u8(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:WQe(u,e),z:V8(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&&B8(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function GQe(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 B8(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=L8(I8,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}GQe(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*VQe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=KQe(e,u,o,s,a&&!R8(c)?F8: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 V8(e,t,n){let r=n8(e.zIndex)?e.zIndex:0;return R8(n)?r:r+(e.selected?t:0)}function KQe(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=u8(e),l=z6(e,n),u=l8(e.extent)?W6(l,e.extent,c):l,d=W6({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=G6(d,c,t));let f=V8(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function H8(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=$6(a.get(n.parentId)?.expandedRect??Z6(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=u8(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 qQe(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=h8(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=l8(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=G6(h,s,t.get(e.parentId)):m&&(h=W6(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:b8(`source`,r.nodeElement,p,d,e.id),target:b8(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&B8(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:Z6(g,i)}))}}if(f.length>0){let e=H8(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function JQe({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 U8(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 W8(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}`;U8(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),U8(`target`,s,c,e,i,o),t.set(r.id,r)}}function G8(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:G8(n,t):!1}function K8(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 YQe(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!G8(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 q8({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 XQe({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=r8(a,t);return{x:o.x-a.x,y:o.y-a.y}}function ZQe({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=W4(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?Y6(B6(s)):null,x=v&&l?XQe({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)}:r8(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}=H6({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]=q8({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]=q6(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=m8(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=YQe(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=q8({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=$4().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=m8(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=y8(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=m8(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=y8(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=y8(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]=q8({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||!K8(t,`.${g}`,v))&&(!_||K8(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function QQe(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())e8(i,Z6(e))>0&&r.push(e);return r}var $Qe=250;function e$e(e,t,n,r){let i=[],a=1/0,o=QQe(e,n,t+$Qe);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}=M8(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 J8(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,...M8(o,c,c.position,!0)}:c}function Y8(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function t$e(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var X8=()=>!0;function n$e(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:_=X8,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=g8(e.target),E=0,D,{x:O,y:k}=y8(e),A=Y8(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=J8(i,A,r,c,t);if(!N)return;let P=y8(e,j),F=!1,I=null,L=!1,R=null;function ee(){if(!u||!j)return;let[e,t]=q6(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:M8(te,z,P6.Left,!0),fromHandle:z,fromPosition:z.position,fromNode:te,to:P,toHandle:null,toPosition:F6[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}=y8(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=y8(e,j),D=e$e(i8(P,a,!1,[1,1]),n,c,z),F||=(ee(),!0);let s=Z8(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=t$e(!!D,s.isValid);let u=c.get(i),f=u?M8(u,z,P6.Left,!0):B.from,p={...B,from:f,isValid:L,to:s.toHandle&&L?a8({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:F6[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 Z8(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=X8,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}=y8(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=Y8(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===O6.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=J8(t,e,a,u,n,!0)}return _}var Q8={onPointerDown:n$e,isValid:Z8};function r$e({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=W4(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&&c8()?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=C6().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:G4}}var $8=e=>({x:e.x,y:e.y,zoom:e.k}),e5=({x:e,y:t,zoom:n})=>v6.translate(e,t).scale(n),t5=(e,t)=>e.target.closest(`.${t}`),n5=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),i$e=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,r5=(e,t=0,n=i$e,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},i5=e=>{let t=e.ctrlKey&&c8()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function a$e({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(t5(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=G4(u),t=d*2**i5(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===k6.Vertical?0:u.deltaX*f,m=i===k6.Horizontal?0:u.deltaY*f;!c8()&&u.shiftKey&&i!==k6.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=$8(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 o$e({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=t5(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function s$e({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=$8(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 c$e({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&n5(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,$8(a.transform))}}function l$e({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&n5(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=$8(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function u$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`&&(t5(d,`${l}-flow__node`)||t5(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||t5(d,s)&&m||t5(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 d$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=C6().scaleExtent([t,n]).translateExtent(r),f=W4(e).call(d);v({x:i.x,y:i.y,zoom:U6(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(i5);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?P3:V3).transform(r5(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:!n8(E)||E<0?0:E);let k=O?a$e({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):o$e({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,k,{passive:!1}),!r){let e=s$e({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=c$e({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=l$e({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let A=u$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=e5(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=e5(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=e5(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?y6(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`?P3:V3).scaleTo(r5(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`?P3:V3).scaleBy(r5(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=!n8(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 a5;(function(e){e.Line=`line`,e.Handle=`handle`})(a5||={});function f$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 o5(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 s5(e,t){return Math.max(0,t-e)}function c5(e,t){return Math.max(0,e-t)}function l5(e,t,n){return Math.max(0,t-e,e-n)}function u5(e,t){return e?!t:t}function p$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=l5(E,h,g),j=l5(D,_,v);if(o){let e=0,t=0;c&&w<0?e=s5(y+w+O,o[0][0]):!c&&w>0&&(e=c5(y+E+O,o[1][0])),l&&T<0?t=s5(b+T+k,o[0][1]):!l&&T>0&&(t=c5(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=c5(y+w,s[0][0]):!c&&w<0&&(e=s5(y+E,s[1][0])),l&&T>0?t=c5(b+T,s[0][1]):!l&&T<0&&(t=s5(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=l5(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?c5(b+k+E/C,o[1][1])*C:s5(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?s5(b+E/C,s[1][1])*C:c5(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=l5(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?c5(y+D*C+O,o[1][0])/C:s5(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?s5(y+D*C,s[1][0])/C:c5(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=(u5(c,l)?-w:w)/C:w=(u5(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 d5={width:0,height:0,x:0,y:0},m$e={...d5,pointerX:0,pointerY:0,aspectRatio:1};function h$e(e){return[[0,0],[e.measured.width,e.measured.height]]}function g$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 _$e({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=W4(e),o={controlDirection:o5(`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={...d5},h={...m$e};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:o5(e)};let g,_=null,v=[],y,b,x,S=!1,C=$4().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}=m8(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`?h$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=g$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=m8(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}=p$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=f$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 f5=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},v$e=e=>e?f5(e):f5,{useDebugValue:y$e}=C.default,{useSyncExternalStoreWithSelector:b$e}=KC.default,x$e=e=>e;function p5(e,t=x$e,n){let r=b$e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return y$e(r),r}var m5=(e,t)=>{let n=v$e(e),r=(e,r=t)=>p5(n,e,r);return Object.assign(r,n),r},S$e=(e,t)=>e?m5(e,t):m5;function h5(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 g5=(0,C.createContext)(null),C$e=g5.Provider,_5=w6.error001();function v5(e,t){let n=(0,C.useContext)(g5);if(n===null)throw Error(_5);return p5(n,e,t)}function y5(){let e=(0,C.useContext)(g5);if(e===null)throw Error(_5);return(0,C.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var b5={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%)`},x5=`react-flow__node-desc`,S5=`react-flow__edge-desc`,T$e=`react-flow__aria-live`,E$e=e=>e.ariaLiveMessage,D$e=e=>e.ariaLabelConfig;function O$e({rfId:e}){let t=v5(E$e);return(0,G.jsx)(`div`,{id:`${T$e}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:w$e,children:t})}function k$e({rfId:e,disableKeyboardA11y:t}){let n=v5(D$e);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{id:`${x5}-${e}`,style:b5,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,G.jsx)(`div`,{id:`${S5}-${e}`,style:b5,children:n[`edge.a11yDescription.default`]}),!t&&(0,G.jsx)(O$e,{rfId:e})]})}var C5=(0,C.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,G.jsx)(`div`,{className:b4([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));C5.displayName=`Panel`;function A$e({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,G.jsx)(C5,{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 j$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}},w5=e=>e.id;function M$e(e,t){return h5(e.selectedNodes.map(w5),t.selectedNodes.map(w5))&&h5(e.selectedEdges.map(w5),t.selectedEdges.map(w5))}function N$e({onSelectionChange:e}){let t=y5(),{selectedNodes:n,selectedEdges:r}=v5(j$e,M$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 P$e=e=>!!e.onSelectionChangeHandlers;function F$e({onSelectionChange:e}){let t=v5(P$e);return e||t?(0,G.jsx)(N$e,{onSelectionChange:e}):null}var T5=typeof window<`u`?C.useLayoutEffect:C.useEffect,E5=[0,0],I$e={x:0,y:0,zoom:1},D5=[...`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`],L$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}),O5={translateExtent:T6,nodeOrigin:E5,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function R$e(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=v5(L$e,h5),l=y5();T5(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=O5,s()}),[]);let u=(0,C.useRef)(O5);return T5(()=>{for(let s of D5){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:kQe(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},D5.map(t=>e[t])),null}function k5(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function z$e(e){let[t,n]=(0,C.useState)(e===`system`?null:e);return(0,C.useEffect)(()=>{if(e!==`system`){n(e);return}let t=k5(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?k5()?.matches?`dark`:`light`:t}var A5=typeof document<`u`?document:null;function j5(e=null,t={target:A5,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(`+`,`
460
460
  `).replace(`
461
461
 
462
462
  `,`
463
463
  +`).split(`
464
464
  `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,C.useEffect)(()=>{let n=t?.target??A5,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&_8(e))return!1;let n=N5(e.code,s);if(a.current.add(e[n]),M5(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=N5(e.code,s);M5(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function M5(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function N5(e,t){return t.includes(e)?`code`:`key`}var B$e=()=>{let e=y5();return(0,C.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=s8(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return i8(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=a8(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function P5(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)V$e(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function V$e(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function F5(e,t){return P5(e,t)}function I5(e,t){return P5(e,t)}function L5(e,t){return{id:e,type:`select`,selected:t}}function R5(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(L5(a.id,e)))}return r}function z5({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function B5(e){return{id:e.id,type:`remove`}}var V5=e=>yQe(e),H$e=e=>L6(e);function H5(e){return(0,C.forwardRef)(e)}function U5(e){let[t,n]=(0,C.useState)(BigInt(0)),[r]=(0,C.useState)(()=>U$e(()=>n(e=>e+BigInt(1))));return T5(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function U$e(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var W5=(0,C.createContext)(null);function W$e({children:e}){let t=y5(),n=U5((0,C.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=z5({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=U5((0,C.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(z5({items:s,lookup:o}))},[])),i=(0,C.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,G.jsx)(W5.Provider,{value:i,children:e})}function G$e(){let e=(0,C.useContext)(W5);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var K$e=e=>!!e.panZoom;function G5(){let e=B$e(),t=y5(),n=G$e(),r=v5(K$e),i=(0,C.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=V5(e)?e:n.get(e.id),a=i.parentId?f8(i.position,i.measured,i.parentId,n,r):i.position;return Z6({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&V5(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&H$e(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await wQe({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(B5);o?.(f),c(e)}if(m){let e=d.map(B5);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=t8(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=Z6(s?r:a),l=e8(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=t8(e)?e:a(e);if(!r)return!1;let i=e8(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return bQe(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??OQe();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,C.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var K5=e=>e.selected,q$e=typeof window<`u`?window:void 0;function J$e({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=y5(),{deleteElements:r}=G5(),i=j5(e,{actInsideInputWithModifier:!1}),a=j5(t,{target:q$e});(0,C.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(K5),edges:e.filter(K5)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,C.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Y$e(e){let t=y5();(0,C.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=h8(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,w6.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var q5={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},X$e=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Z$e({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=k6.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=y5(),S=(0,C.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=v5(X$e,h5),D=j5(f),O=(0,C.useRef)();Y$e(S);let k=(0,C.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,C.useEffect)(()=>{if(S.current){O.current=d$e({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return x.setState({panZoom:O.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,C.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:D,preventScrolling:p,noPanClassName:g,userSelectionActive:w,noWheelClassName:h,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,D,p,g,w,h,T,k,E,b,y]),(0,G.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:q5,children:m})}var Q$e=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function $$e(){let{userSelectionActive:e,userSelectionRect:t}=v5(Q$e,h5);return e&&t?(0,G.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var J5=(e,t)=>n=>{n.target===t.current&&e?.(n)},e1e=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function t1e({isSelecting:e,selectionKeyPressed:t,selectionMode:n=A6.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=y5(),{userSelectionActive:g,elementsSelectable:_,dragging:v,connectionInProgress:y}=v5(e1e,h5),b=_&&(e||g),x=(0,C.useRef)(null),S=(0,C.useRef)(),w=(0,C.useRef)(new Set),T=(0,C.useRef)(new Set),E=(0,C.useRef)(!1),D=e=>{if(E.current||y){E.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},O=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},k=u?e=>u(e):void 0;return(0,G.jsxs)(`div`,{className:b4([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:v,selection:e}]),onClick:b?void 0:J5(D,x),onContextMenu:J5(O,x),onWheel:J5(k,x),onPointerEnter:b?void 0:d,onPointerMove:b?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!S.current||!r)return;let{x:m,y:g}=y8(e.nativeEvent,S.current),{startX:_,startY:v}=r;if(!E.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}E.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:g<v?g:v,width:Math.abs(m-_),height:Math.abs(g-v)},b=w.current,x=T.current;w.current=new Set(V6(s,y,a,n===A6.Partial,!0).map(e=>e.id)),T.current=new Set;let C=f?.selectable??!0;for(let e of w.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??C)&&T.current.add(e)}}p8(b,w.current)||u(R5(s,w.current,!0)),p8(x,T.current)||d(R5(c,T.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:b?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===x.current&&h.getState().userSelectionRect&&D?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),E.current&&(s?.(e),h.setState({nodesSelectionActive:w.current.size>0})))}:void 0,onPointerDownCapture:b?n=>{let{domNode:r}=h.getState();if(S.current=r?.getBoundingClientRect(),!S.current)return;let i=n.target===x.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),E.current=!1;let{x:o,y:s}=y8(n.nativeEvent,S.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:b?e=>{E.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:x,style:q5,children:[m,(0,G.jsx)($$e,{})]})}function Y5({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,w6.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function X5({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=y5(),[c,l]=(0,C.useState)(!1),u=(0,C.useRef)();return(0,C.useEffect)(()=>{u.current=ZQe({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{Y5({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,C.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var n1e=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Z5(){let e=y5();return(0,C.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=n1e(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=r8(t,i));let{position:a,positionAbsolute:s}=H6({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var Q5=(0,C.createContext)(null),r1e=Q5.Provider;Q5.Consumer;var $5=()=>(0,C.useContext)(Q5),i1e=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),a1e=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===O6.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function o1e({type:e=`source`,position:t=P6.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=y5(),_=$5(),{connectOnClick:v,noPanClassName:y,rfId:b}=v5(i1e,h5),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=v5(a1e(_,m,e),h5);_||g.getState().onError?.(`010`,w6.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(FQe(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=v8(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();Q8.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,G.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:b4([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=g8(t.target),h=n||c,{connection:v,isValid:y}=Q8.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var e7=(0,C.memo)(H5(o1e));function s1e({data:e,isConnectable:t,sourcePosition:n=P6.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[e?.label,(0,G.jsx)(e7,{type:`source`,position:n,isConnectable:t})]})}function c1e({data:e,isConnectable:t,targetPosition:n=P6.Top,sourcePosition:r=P6.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(e7,{type:`target`,position:n,isConnectable:t}),e?.label,(0,G.jsx)(e7,{type:`source`,position:r,isConnectable:t})]})}function l1e(){return null}function u1e({data:e,isConnectable:t,targetPosition:n=P6.Top}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(e7,{type:`target`,position:n,isConnectable:t}),e?.label]})}var t7={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},n7={input:s1e,default:c1e,output:u1e,group:l1e};function d1e(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var f1e=e=>{let{width:t,height:n,x:r,y:i}=B6(e.nodeLookup,{filter:e=>!!e.selected});return{width:n8(t)?t:null,height:n8(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function p1e({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=y5(),{width:i,height:a,transformString:o,userSelectionActive:s}=v5(f1e,h5),c=Z5(),l=(0,C.useRef)(null);(0,C.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(X5({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,G.jsx)(`div`,{className:b4([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,G.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(t7,e.key)&&(e.preventDefault(),c({direction:t7[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var r7=typeof window<`u`?window:void 0,m1e=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function i7({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:P,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=v5(m1e,h5),R=j5(l,{target:r7}),ee=j5(h,{target:r7}),z=ee||w,te=ee||b,B=u&&z!==!0,V=R||L||B;return J$e({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,G.jsx)(Z$e,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:te,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!R&&z,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:P,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:B,children:(0,G.jsxs)(t1e,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:z,isSelecting:!!V,selectionMode:d,selectionKeyPressed:R,paneClickDistance:s,selectionOnDrag:B,children:[e,I&&(0,G.jsx)(p1e,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}i7.displayName=`FlowRenderer`;var h1e=(0,C.memo)(i7),g1e=e=>t=>e?V6(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function _1e(e){return v5((0,C.useCallback)(g1e(e),[e]),h5)}var v1e=e=>e.updateNodeInternals;function y1e(){let e=v5(v1e),[t]=(0,C.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,C.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function b1e({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=y5(),a=(0,C.useRef)(null),o=(0,C.useRef)(null),s=(0,C.useRef)(e.sourcePosition),c=(0,C.useRef)(e.targetPosition),l=(0,C.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,C.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,C.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,C.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function x1e({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=v5(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},h5),S=y.type||`default`,C=g?.[S]||n7[S];C===void 0&&(v?.(`003`,w6.error003(S)),S=`default`,C=g?.default||n7.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=y5(),k=d8(y),A=b1e({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=X5({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=Z5();if(y.hidden)return null;let N=u8(y),P=d1e(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,ee=a?e=>a(e,{...b.userNode}):void 0,z=o?e=>o(e,{...b.userNode}):void 0,te=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&Y5({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},B=t=>{if(!(_8(t.nativeEvent)||m)){if(E6.includes(t.key)&&T)Y5({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(t7,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:t7[t.key],factor:t.shiftKey?4:1})}}},V=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(V6(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,G.jsx)(`div`,{className:b4([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:ee,onClick:te,onDoubleClick:z,onKeyDown:D?B:void 0,tabIndex:D?0:void 0,onFocus:D?V:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${x5}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,G.jsx)(r1e,{value:e,children:(0,G.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var S1e=(0,C.memo)(x1e),C1e=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function a7(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=v5(C1e,h5),o=_1e(e.onlyRenderVisibleElements),s=y1e();return(0,G.jsx)(`div`,{className:`react-flow__nodes`,style:q5,children:o.map(o=>(0,G.jsx)(S1e,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}a7.displayName=`NodeRenderer`;var w1e=(0,C.memo)(a7);function T1e(e){return v5((0,C.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&MQe({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),h5)}var E1e=({color:e=`none`,strokeWidth:t=1})=>(0,G.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),D1e=({color:e=`none`,strokeWidth:t=1})=>(0,G.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),o7={[N6.Arrow]:E1e,[N6.ArrowClosed]:D1e};function O1e(e){let t=y5();return(0,C.useMemo)(()=>Object.prototype.hasOwnProperty.call(o7,e)?o7[e]:(t.getState().onError?.(`009`,w6.error009(e)),null),[e])}var k1e=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=O1e(t);return c?(0,G.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,G.jsx)(c,{color:n,strokeWidth:o})}):null},s7=({defaultColor:e,rfId:t})=>{let n=v5(e=>e.edges),r=v5(e=>e.defaultEdgeOptions),i=(0,C.useMemo)(()=>BQe(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,G.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,G.jsx)(`defs`,{children:i.map(e=>(0,G.jsx)(k1e,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};s7.displayName=`MarkerDefinitions`;var A1e=(0,C.memo)(s7);function c7({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,C.useState)({x:1,y:0,width:0,height:0}),p=b4([`react-flow__edge-textwrapper`,l]),m=(0,C.useRef)(null);return(0,C.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,G.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,G.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,G.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}c7.displayName=`EdgeText`;var j1e=(0,C.memo)(c7);function l7({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{...u,d:e,fill:`none`,className:b4([`react-flow__edge-path`,u.className])}),l?(0,G.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&n8(t)&&n8(n)?(0,G.jsx)(j1e,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function u7({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===P6.Left||e===P6.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function d7({sourceX:e,sourceY:t,sourcePosition:n=P6.Bottom,targetX:r,targetY:i,targetPosition:a=P6.Top}){let[o,s]=u7({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=u7({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=x8({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function f7(e){return(0,C.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=d7({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,G.jsx)(l7,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var M1e=f7({isInternal:!1}),p7=f7({isInternal:!0});M1e.displayName=`SimpleBezierEdge`,p7.displayName=`SimpleBezierEdgeInternal`;function m7(e){return(0,C.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=P6.Bottom,targetPosition:m=P6.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=k8({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,G.jsx)(l7,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var h7=m7({isInternal:!1}),g7=m7({isInternal:!0});h7.displayName=`SmoothStepEdge`,g7.displayName=`SmoothStepEdgeInternal`;function _7(e){return(0,C.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,G.jsx)(h7,{...n,id:r,pathOptions:(0,C.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var N1e=_7({isInternal:!1}),v7=_7({isInternal:!0});N1e.displayName=`StepEdge`,v7.displayName=`StepEdgeInternal`;function y7(e){return(0,C.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=E8({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,G.jsx)(l7,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var P1e=y7({isInternal:!1}),b7=y7({isInternal:!0});P1e.displayName=`StraightEdge`,b7.displayName=`StraightEdgeInternal`;function x7(e){return(0,C.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=P6.Bottom,targetPosition:s=P6.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=w8({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,G.jsx)(l7,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var F1e=x7({isInternal:!1}),S7=x7({isInternal:!0});F1e.displayName=`BezierEdge`,S7.displayName=`BezierEdgeInternal`;var C7={default:S7,straight:b7,step:v7,smoothstep:g7,simplebezier:p7},w7={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},I1e=(e,t,n)=>n===P6.Left?e-t:n===P6.Right?e+t:e,L1e=(e,t,n)=>n===P6.Top?e-t:n===P6.Bottom?e+t:e,T7=`react-flow__edgeupdater`;function E7({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,G.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:b4([T7,`${T7}-${s}`]),cx:I1e(t,r,e),cy:L1e(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function R1e({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=y5(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;Q8.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,G.jsxs)(G.Fragment,{children:[(e===!0||e===`source`)&&(0,G.jsx)(E7,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,G.jsx)(E7,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function z1e({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=v5(t=>t.edgeLookup.get(e)),b=v5(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||C7[x];S===void 0&&(_?.(`011`,w6.error011(x)),x=`default`,S=h?.default||C7.default);let w=!!(y.focusable||t&&y.focusable===void 0),T=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),E=!!(y.selectable||r&&y.selectable===void 0),D=(0,C.useRef)(null),[O,k]=(0,C.useState)(!1),[A,j]=(0,C.useState)(!1),M=y5(),{zIndex:N,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:ee}=v5((0,C.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return{zIndex:y.zIndex,...w7};let i=zQe({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:jQe({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||w7}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),h5),z=(0,C.useMemo)(()=>y.markerStart?`url('#${P8(y.markerStart,m)}')`:void 0,[y.markerStart,m]),te=(0,C.useMemo)(()=>y.markerEnd?`url('#${P8(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||P===null||F===null||I===null||L===null)return null;let B=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=M.getState();E&&(M.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),D.current?.blur()):n([e])),i&&i(t,y)},V=a?e=>{a(e,{...y})}:void 0,ne=o?e=>{o(e,{...y})}:void 0,re=s?e=>{s(e,{...y})}:void 0,ie=c?e=>{c(e,{...y})}:void 0,ae=l?e=>{l(e,{...y})}:void 0;return(0,G.jsx)(`svg`,{style:{zIndex:N},children:(0,G.jsxs)(`g`,{className:b4([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!E&&!i,updating:O,selectable:E}]),onClick:B,onDoubleClick:V,onContextMenu:ne,onMouseEnter:re,onMouseMove:ie,onMouseLeave:ae,onKeyDown:w?t=>{if(!v&&E6.includes(t.key)&&E){let{unselectNodesAndEdges:n,addSelectedEdges:r}=M.getState();t.key===`Escape`?(D.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:w?0:void 0,role:y.ariaRole??(w?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":w?`${S5}-${m}`:void 0,ref:D,...y.domAttributes,children:[!A&&(0,G.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:E,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:ee,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:te,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),T&&(0,G.jsx)(R1e,{edge:y,isReconnectable:T,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:P,sourceY:F,targetX:I,targetY:L,sourcePosition:R,targetPosition:ee,setUpdateHover:k,setReconnecting:j})]})})}var B1e=(0,C.memo)(z1e),V1e=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function D7({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=v5(V1e,h5),b=T1e(t);return(0,G.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,G.jsx)(A1e,{defaultColor:e,rfId:n}),b.map(e=>(0,G.jsx)(B1e,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}D7.displayName=`EdgeRenderer`;var H1e=(0,C.memo)(D7),U1e=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function W1e({children:e}){return(0,G.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:v5(U1e)},children:e})}function G1e(e){let t=G5(),n=(0,C.useRef)(!1);(0,C.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var K1e=e=>e.panZoom?.syncViewport;function q1e(e){let t=v5(K1e),n=y5();return(0,C.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function O7(e){return e.connection.inProgress?{...e.connection,to:i8(e.connection.to,e.transform)}:{...e.connection}}function J1e(e){return e?t=>e(O7(t)):O7}function Y1e(e){return v5(J1e(e),h5)}var X1e=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Z1e({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=v5(X1e,h5);return a&&i&&c?(0,G.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,G.jsx)(`g`,{className:b4([`react-flow__connection`,I6(s)]),children:(0,G.jsx)(k7,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var k7=({style:e,type:t=M6.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Y1e();if(!i)return;if(n)return(0,G.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:I6(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case M6.Bezier:[m]=w8(h);break;case M6.SimpleBezier:[m]=d7(h);break;case M6.Step:[m]=k8({...h,borderRadius:0});break;case M6.SmoothStep:[m]=k8(h);break;default:[m]=E8(h)}return(0,G.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};k7.displayName=`ConnectionLine`;var Q1e={};function A7(e=Q1e){(0,C.useRef)(e),y5(),(0,C.useEffect)(()=>{},[e])}function $1e(){y5(),(0,C.useRef)(!1),(0,C.useEffect)(()=>{},[])}function j7({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:ee,onPaneClick:z,onPaneMouseEnter:te,onPaneMouseMove:B,onPaneMouseLeave:V,onPaneScroll:ne,onPaneContextMenu:re,paneClickDistance:ie,nodeClickDistance:ae,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,onReconnect:H,onReconnectStart:de,onReconnectEnd:fe,noDragClassName:U,noWheelClassName:pe,noPanClassName:me,disableKeyboardA11y:W,nodeExtent:he,rfId:ge,viewport:_e,onViewportChange:ve}){return A7(e),A7(t),$1e(),G1e(n),q1e(_e),(0,G.jsx)(h1e,{onPaneClick:z,onPaneMouseEnter:te,onPaneMouseMove:B,onPaneMouseLeave:V,onPaneContextMenu:re,onPaneScroll:ne,paneClickDistance:ie,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:ee,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:U,noWheelClassName:pe,noPanClassName:me,disableKeyboardA11y:W,onViewportChange:ve,isControlledViewport:!!_e,children:(0,G.jsxs)(W1e,{children:[(0,G.jsx)(H1e,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:H,onReconnectStart:de,onReconnectEnd:fe,onlyRenderVisibleElements:T,onEdgeContextMenu:oe,onEdgeMouseEnter:se,onEdgeMouseMove:ce,onEdgeMouseLeave:le,reconnectRadius:ue,defaultMarkerColor:M,noPanClassName:me,disableKeyboardA11y:W,rfId:ge}),(0,G.jsx)(Z1e,{style:h,type:m,component:g,containerStyle:_}),(0,G.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,G.jsx)(w1e,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ae,onlyRenderVisibleElements:T,noPanClassName:me,noDragClassName:U,disableKeyboardA11y:W,nodeExtent:he,rfId:ge}),(0,G.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}j7.displayName=`GraphView`;var e0e=(0,C.memo)(j7),M7=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??T6;W8(h,g,_);let{nodesInitialized:x}=z8(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=s8(B6(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:T6,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:O6.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...j6},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:TQe,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:D6,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},t0e=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>S$e((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await CQe({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...M7({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=z8(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();W8(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=qQe(e,n,r,i,a,o,l);d&&(UQe(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=M8(e,o.fromHandle,P6.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=H8(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(F5(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(I5(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>L5(e,!0)));return}i(R5(r,new Set([...e]),!0)),a(R5(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>L5(e,!0)));return}a(R5(n,new Set([...e]))),i(R5(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(L5(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(L5(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,L5(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,L5(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(z8(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return JQe({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...j6}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...M7()})}},Object.is);function n0e({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,C.useState)(()=>t0e({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,G.jsx)(C$e,{value:m,children:(0,G.jsx)(W$e,{children:p})})}function r0e({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,C.useContext)(g5)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(n0e,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var i0e={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function a0e({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onSelectionChange:A,onSelectionDragStart:j,onSelectionDrag:M,onSelectionDragStop:N,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onBeforeDelete:L,connectionMode:R,connectionLineType:ee=M6.Bezier,connectionLineStyle:z,connectionLineComponent:te,connectionLineContainerStyle:B,deleteKeyCode:V=`Backspace`,selectionKeyCode:ne=`Shift`,selectionOnDrag:re=!1,selectionMode:ie=A6.Full,panActivationKeyCode:ae=`Space`,multiSelectionKeyCode:oe=c8()?`Meta`:`Control`,zoomActivationKeyCode:se=c8()?`Meta`:`Control`,snapToGrid:ce,snapGrid:le,onlyRenderVisibleElements:ue=!1,selectNodesOnDrag:H,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:U,nodesFocusable:pe,nodeOrigin:me=E5,edgesFocusable:W,edgesReconnectable:he,elementsSelectable:ge=!0,defaultViewport:_e=I$e,minZoom:ve=.5,maxZoom:ye=2,translateExtent:be=T6,preventScrolling:xe=!0,nodeExtent:Se,defaultMarkerColor:Ce=`#b1b1b7`,zoomOnScroll:we=!0,zoomOnPinch:Te=!0,panOnScroll:Ee=!1,panOnScrollSpeed:De=.5,panOnScrollMode:Oe=k6.Free,zoomOnDoubleClick:ke=!0,panOnDrag:Ae=!0,onPaneClick:je,onPaneMouseEnter:Me,onPaneMouseMove:Ne,onPaneMouseLeave:Pe,onPaneScroll:Fe,onPaneContextMenu:Ie,paneClickDistance:Le=1,nodeClickDistance:Re=0,children:ze,onReconnect:Be,onReconnectStart:Ve,onReconnectEnd:He,onEdgeContextMenu:Ue,onEdgeDoubleClick:We,onEdgeMouseEnter:Ge,onEdgeMouseMove:Ke,onEdgeMouseLeave:qe,reconnectRadius:Je=10,onNodesChange:Ye,onEdgesChange:Xe,noDragClassName:Ze=`nodrag`,noWheelClassName:Qe=`nowheel`,noPanClassName:$e=`nopan`,fitView:et,fitViewOptions:tt,connectOnClick:nt,attributionPosition:rt,proOptions:it,defaultEdgeOptions:at,elevateNodesOnSelect:ot=!0,elevateEdgesOnSelect:st=!1,disableKeyboardA11y:ct=!1,autoPanOnConnect:lt,autoPanOnNodeDrag:ut,autoPanSpeed:dt,connectionRadius:ft,isValidConnection:pt,onError:mt,style:ht,id:gt,nodeDragThreshold:_t,connectionDragThreshold:vt,viewport:yt,onViewportChange:bt,width:xt,height:St,colorMode:Ct=`light`,debug:wt,onScroll:Tt,ariaLabelConfig:Et,zIndexMode:Dt=`basic`,...Ot},kt){let At=gt||`1`,jt=z$e(Ct),Mt=(0,C.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Tt?.(e)},[Tt]);return(0,G.jsx)(`div`,{"data-testid":`rf__wrapper`,...Ot,onScroll:Mt,style:{...ht,...i0e},ref:kt,className:b4([`react-flow`,i,jt]),id:gt,role:`application`,children:(0,G.jsxs)(r0e,{nodes:e,edges:t,width:xt,height:St,fitView:et,fitViewOptions:tt,minZoom:ve,maxZoom:ye,nodeOrigin:me,nodeExtent:Se,zIndexMode:Dt,children:[(0,G.jsx)(R$e,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:de,autoPanOnNodeFocus:fe,nodesConnectable:U,nodesFocusable:pe,edgesFocusable:W,edgesReconnectable:he,elementsSelectable:ge,elevateNodesOnSelect:ot,elevateEdgesOnSelect:st,minZoom:ve,maxZoom:ye,nodeExtent:Se,onNodesChange:Ye,onEdgesChange:Xe,snapToGrid:ce,snapGrid:le,connectionMode:R,translateExtent:be,connectOnClick:nt,defaultEdgeOptions:at,fitView:et,fitViewOptions:tt,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onSelectionDrag:M,onSelectionDragStart:j,onSelectionDragStop:N,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:$e,nodeOrigin:me,rfId:At,autoPanOnConnect:lt,autoPanOnNodeDrag:ut,autoPanSpeed:dt,onError:mt,connectionRadius:ft,isValidConnection:pt,selectNodesOnDrag:H,nodeDragThreshold:_t,connectionDragThreshold:vt,onBeforeDelete:L,debug:wt,ariaLabelConfig:Et,zIndexMode:Dt}),(0,G.jsx)(e0e,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:ee,connectionLineStyle:z,connectionLineComponent:te,connectionLineContainerStyle:B,selectionKeyCode:ne,selectionOnDrag:re,selectionMode:ie,deleteKeyCode:V,multiSelectionKeyCode:oe,panActivationKeyCode:ae,zoomActivationKeyCode:se,onlyRenderVisibleElements:ue,defaultViewport:_e,translateExtent:be,minZoom:ve,maxZoom:ye,preventScrolling:xe,zoomOnScroll:we,zoomOnPinch:Te,zoomOnDoubleClick:ke,panOnScroll:Ee,panOnScrollSpeed:De,panOnScrollMode:Oe,panOnDrag:Ae,onPaneClick:je,onPaneMouseEnter:Me,onPaneMouseMove:Ne,onPaneMouseLeave:Pe,onPaneScroll:Fe,onPaneContextMenu:Ie,paneClickDistance:Le,nodeClickDistance:Re,onSelectionContextMenu:P,onSelectionStart:F,onSelectionEnd:I,onReconnect:Be,onReconnectStart:Ve,onReconnectEnd:He,onEdgeContextMenu:Ue,onEdgeDoubleClick:We,onEdgeMouseEnter:Ge,onEdgeMouseMove:Ke,onEdgeMouseLeave:qe,reconnectRadius:Je,defaultMarkerColor:Ce,noDragClassName:Ze,noWheelClassName:Qe,noPanClassName:$e,rfId:At,disableKeyboardA11y:ct,nodeExtent:Se,viewport:yt,onViewportChange:bt}),(0,G.jsx)(F$e,{onSelectionChange:A}),ze,(0,G.jsx)(A$e,{proOptions:it,position:rt}),(0,G.jsx)(k$e,{rfId:At,disableKeyboardA11y:ct})]})})}var o0e=H5(a0e);function s0e(e){let[t,n]=(0,C.useState)(e);return[t,n,(0,C.useCallback)(e=>n(t=>F5(e,t)),[])]}function c0e(e){let[t,n]=(0,C.useState)(e);return[t,n,(0,C.useCallback)(e=>n(t=>I5(e,t)),[])]}w6.error014();function l0e({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,G.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:b4([`react-flow__background-pattern`,n,r])})}function u0e({radius:e,className:t}){return(0,G.jsx)(`circle`,{cx:e,cy:e,r:e,className:b4([`react-flow__background-pattern`,`dots`,t])})}var N7;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(N7||={});var d0e={[N7.Dots]:1,[N7.Lines]:1,[N7.Cross]:6},f0e=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function P7({id:e,variant:t=N7.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,C.useRef)(null),{transform:f,patternId:p}=v5(f0e,h5),m=r||d0e[t],h=t===N7.Dots,g=t===N7.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],w=`${p}${e||``}`;return(0,G.jsxs)(`svg`,{className:b4([`react-flow__background`,l]),style:{...c,...q5,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,G.jsx)(`pattern`,{id:w,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,G.jsx)(u0e,{radius:y/2,className:u}):(0,G.jsx)(l0e,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,G.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${w})`})]})}P7.displayName=`Background`;var p0e=(0,C.memo)(P7);function m0e(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,G.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function h0e(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,G.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function g0e(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,G.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function _0e(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,G.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function v0e(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,G.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function F7({children:e,className:t,...n}){return(0,G.jsx)(`button`,{type:`button`,className:b4([`react-flow__controls-button`,t]),...n,children:e})}var y0e=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function I7({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=y5(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=v5(y0e,h5),{zoomIn:y,zoomOut:b,fitView:x}=G5();return(0,G.jsxs)(C5,{className:b4([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(F7,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,G.jsx)(m0e,{})}),(0,G.jsx)(F7,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,G.jsx)(h0e,{})})]}),n&&(0,G.jsx)(F7,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,G.jsx)(g0e,{})}),r&&(0,G.jsx)(F7,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,G.jsx)(v0e,{}):(0,G.jsx)(_0e,{})}),u]})}I7.displayName=`Controls`;var b0e=(0,C.memo)(I7);function x0e({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,G.jsx)(`rect`,{className:b4([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var S0e=(0,C.memo)(x0e),C0e=e=>e.nodes.map(e=>e.id),L7=e=>e instanceof Function?e:()=>e;function w0e({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=S0e,onClick:o}){let s=v5(C0e,h5),c=L7(t),l=L7(e),u=L7(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,G.jsx)(G.Fragment,{children:s.map(e=>(0,G.jsx)(E0e,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function T0e({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=v5(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=u8(r);return{node:r,x:i,y:a,width:o,height:s}},h5);return!l||l.hidden||!d8(l)?null:(0,G.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var E0e=(0,C.memo)(T0e),D0e=(0,C.memo)(w0e),O0e=200,k0e=150,A0e=e=>!e.hidden,j0e=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?$6(B6(e.nodeLookup,{filter:A0e}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},M0e=`react-flow__minimap-desc`;function R7({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=y5(),S=(0,C.useRef)(null),{boundingRect:w,viewBB:T,rfId:E,panZoom:D,translateExtent:O,flowWidth:k,flowHeight:A,ariaLabelConfig:j}=v5(j0e,h5),M=e?.width??O0e,N=e?.height??k0e,P=w.width/M,F=w.height/N,I=Math.max(P,F),L=I*M,R=I*N,ee=b*I,z=w.x-(L-w.width)/2-ee,te=w.y-(R-w.height)/2-ee,B=L+ee*2,V=R+ee*2,ne=`${M0e}-${E}`,re=(0,C.useRef)(0),ie=(0,C.useRef)();re.current=I,(0,C.useEffect)(()=>{if(S.current&&D)return ie.current=r$e({domNode:S.current,panZoom:D,getTransform:()=>x.getState().transform,getViewScale:()=>re.current}),()=>{ie.current?.destroy()}},[D]),(0,C.useEffect)(()=>{ie.current?.update({translateExtent:O,width:k,height:A,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,O,k,A]);let ae=p?e=>{let[t,n]=ie.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,oe=m?(0,C.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,se=_??j[`minimap.ariaLabel`];return(0,G.jsx)(C5,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*I:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:b4([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,G.jsxs)(`svg`,{width:M,height:N,viewBox:`${z} ${te} ${B} ${V}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ne,ref:S,onClick:ae,children:[se&&(0,G.jsx)(`title`,{id:ne,children:se}),(0,G.jsx)(D0e,{onClick:oe,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,G.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-ee},${te-ee}h${B+ee*2}v${V+ee*2}h${-B-ee*2}z
465
- M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}R7.displayName=`MiniMap`;var N0e=(0,C.memo)(R7),P0e=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,F0e={[a5.Line]:`right`,[a5.Handle]:`bottom-right`};function I0e({nodeId:e,position:t,variant:n=a5.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=$5(),y=typeof e==`string`?e:v,b=y5(),x=(0,C.useRef)(null),S=n===a5.Handle,w=v5((0,C.useCallback)(P0e(S&&p),[S,p]),h5),T=(0,C.useRef)(null),E=t??F0e[n];return(0,C.useEffect)(()=>{if(!(!x.current||!y))return T.current||=_$e({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=H8([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...f8({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{T.current?.destroy()}},[E,s,c,l,u,d,h,g,_,m]),(0,G.jsx)(`div`,{className:b4([`react-flow__resize-control`,`nodrag`,...E.split(`-`),n,r]),ref:x,style:{...i,scale:w,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,C.memo)(I0e);function L0e(e){return{running:{color:e?`#81c784`:`#2e7d32`,bg:e?`#1b3a1b`:`#e8f5e9`,border:`#4caf50`,Icon:gv},starting:{color:e?`#ffb74d`:`#ed6c02`,bg:e?`#3a2a10`:`#fff3e0`,border:`#ff9800`,Icon:Zhe},stopped:{color:e?`#bdbdbd`:`#757575`,bg:e?`#2a2a2a`:`#f5f5f5`,border:e?`#616161`:`#bdbdbd`,Icon:uge},failed:{color:e?`#ef5350`:`#d32f2f`,bg:e?`#3a1515`:`#ffebee`,border:`#f44336`,Icon:Ox}}}var R0e={hub:({data:e})=>{let{label:t,bridgeCount:n,deviceCount:r}=e,i=wm(),a=i.palette.primary.main,o=i.palette.primary.dark;return(0,G.jsxs)(Z,{sx:{background:`linear-gradient(135deg, ${a}, ${o})`,borderRadius:`50%`,width:120,height:120,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,color:i.palette.primary.contrastText,boxShadow:`0 4px 20px ${i.palette.mode===`dark`?`rgba(0,0,0,0.5)`:`rgba(25,118,210,0.4)`}`,border:`3px solid rgba(255,255,255,0.3)`},children:[(0,G.jsx)(aE,{sx:{fontSize:32,mb:.5}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:700,lineHeight:1.1,children:t}),(0,G.jsxs)(Q,{variant:`caption`,sx:{opacity:.8,fontSize:`0.65rem`},children:[n,` bridges · `,r,` devices`]}),(0,G.jsx)(e7,{type:`source`,position:P6.Right,style:{opacity:0}}),(0,G.jsx)(e7,{type:`source`,position:P6.Left,style:{opacity:0},id:`left`}),(0,G.jsx)(e7,{type:`source`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsx)(e7,{type:`source`,position:P6.Bottom,style:{opacity:0},id:`bottom`})]})},bridge:({data:e})=>{let{label:t,status:n,port:r,deviceCount:i,failedCount:a,fabricCount:o}=e,{mode:s}=Pm(),c=L0e(s===`dark`),l=c[n]??c.stopped,{Icon:u}=l;return(0,G.jsxs)(Z,{sx:{background:l.bg,border:`2px solid ${l.border}`,borderRadius:2,px:2,py:1.5,minWidth:180,maxWidth:220,boxShadow:`0 2px 12px rgba(0,0,0,0.08)`},children:[(0,G.jsx)(e7,{type:`target`,position:P6.Left,style:{opacity:0}}),(0,G.jsx)(e7,{type:`target`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsx)(e7,{type:`source`,position:P6.Right,style:{opacity:0}}),(0,G.jsx)(e7,{type:`source`,position:P6.Bottom,style:{opacity:0},id:`bottom`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5,mb:.5},children:[(0,G.jsx)(u,{sx:{fontSize:16,color:l.color}}),(0,G.jsx)(Q,{variant:`subtitle2`,fontWeight:700,noWrap:!0,sx:{color:l.color},children:t})]}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,children:[`Port `,r]}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:.5,mt:.5,flexWrap:`wrap`},children:[(0,G.jsx)(Nv,{label:`${i} devices`,size:`small`,sx:{fontSize:`0.65rem`,height:20}}),o>0&&(0,G.jsx)(Nv,{label:`${o} fabrics`,size:`small`,color:`primary`,variant:`outlined`,sx:{fontSize:`0.65rem`,height:20}}),a>0&&(0,G.jsx)(Nv,{label:`${a} failed`,size:`small`,color:`error`,sx:{fontSize:`0.65rem`,height:20}})]})]})},device:({data:e})=>{let{label:t,deviceType:n}=e;return(0,G.jsxs)(Z,{sx:{background:e=>e.palette.background.paper,border:`1px solid`,borderColor:`divider`,borderRadius:1.5,px:1.5,py:1,minWidth:150,maxWidth:200,boxShadow:`0 1px 6px rgba(0,0,0,0.06)`},children:[(0,G.jsx)(e7,{type:`target`,position:P6.Left,style:{opacity:0}}),(0,G.jsx)(e7,{type:`target`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(xb,{sx:{fontSize:14,color:`text.secondary`}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:600,noWrap:!0,sx:{maxWidth:160},children:t})]}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,sx:{fontSize:`0.6rem`,mt:.25},noWrap:!0,children:n})]})},fabric:({data:e})=>{let{label:t,vendorId:n}=e,r=wm(),i=Dx(n)===`Vendor ${n}`?t||`Vendor ${n}`:Dx(n);return(0,G.jsxs)(Z,{sx:{background:`linear-gradient(135deg, ${r.palette.secondary.dark}, ${r.palette.secondary.main})`,borderRadius:2,px:1.5,py:1,minWidth:140,color:r.palette.secondary.contrastText,boxShadow:`0 2px 12px ${r.palette.mode===`dark`?`rgba(0,0,0,0.4)`:`rgba(123,31,162,0.3)`}`},children:[(0,G.jsx)(e7,{type:`source`,position:P6.Right,style:{opacity:0}}),(0,G.jsx)(e7,{type:`source`,position:P6.Bottom,style:{opacity:0},id:`bottom`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Ihe,{sx:{fontSize:16}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:700,children:i})]}),t&&t!==i&&(0,G.jsx)(Q,{variant:`caption`,display:`block`,sx:{opacity:.8,fontSize:`0.6rem`},children:t})]})},failed:({data:e})=>{let{label:t,reason:n}=e,{mode:r}=Pm(),i=r===`dark`,a=i?`#ef5350`:`#d32f2f`;return(0,G.jsxs)(Z,{sx:{background:i?`#3a1515`:`#ffebee`,border:`1px dashed #f44336`,borderRadius:1.5,px:1.5,py:1,minWidth:150,maxWidth:200,opacity:.85},children:[(0,G.jsx)(e7,{type:`target`,position:P6.Left,style:{opacity:0}}),(0,G.jsx)(e7,{type:`target`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Cb,{sx:{fontSize:14,color:a}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:600,noWrap:!0,sx:{maxWidth:160,color:a},children:t})]}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,sx:{fontSize:`0.6rem`,mt:.25},noWrap:!0,title:n,children:n})]})}};function z7(e){return!e.parts||e.parts.length===0?e.endpoint===0?[]:[e]:e.parts.flatMap(z7)}function z0e(e,t,n,r){let i=[],a=[],o=e.reduce((e,t)=>e+t.deviceCount,0),s=new Map,c=e.map(e=>{let r=t[e.id],i=r?z7(r):[],a=e.failedEntities?.length??0,o=i.length+a,s=Math.min(o,n.devicesPerColumn);return{bridge:e,devices:i,height:Math.max(n.minBridgeSpacingY,s*n.deviceSpacingY+80)}}),l=c.reduce((e,t)=>e+t.height,0)/2;i.push({id:`hub`,type:`hub`,position:{x:n.hubX,y:l-60},data:{label:`HAMH`,bridgeCount:e.length,deviceCount:o}});let u=0;c.forEach(({bridge:e,devices:t,height:o})=>{let c=`bridge-${e.id}`,l=u+o/2,d=n.hubX+n.bridgeOffsetX,f=e.commissioning?.fabrics?.length??0,p=e.failedEntities?.length??0;if(i.push({id:c,type:`bridge`,position:{x:d,y:l-30},data:{label:e.name,status:e.status,port:e.port,deviceCount:e.deviceCount,failedCount:p,fabricCount:f}}),a.push({id:`hub-${c}`,source:`hub`,target:c,type:`smoothstep`,animated:e.status===`running`,style:{stroke:e.status===`running`?r.running:r.inactive,strokeWidth:2}}),e.commissioning?.fabrics)for(let t of e.commissioning.fabrics){let n=s.get(t.rootVendorId);n?n.bridgeIds.includes(e.id)||n.bridgeIds.push(e.id):s.set(t.rootVendorId,{vendorId:t.rootVendorId,label:t.label,bridgeIds:[e.id]})}let m=e.failedEntities??[],h=t.length+m.length,g=l-Math.min(h,n.devicesPerColumn)*n.deviceSpacingY/2,_=d+n.deviceOffsetX;t.forEach((t,o)=>{let s=Math.floor(o/n.devicesPerColumn),l=o%n.devicesPerColumn,u=`device-${e.id}-${t.id.global}`,d=Nx(t.state)??t.id.local;i.push({id:u,type:`device`,position:{x:_+s*n.deviceColumnSpacingX,y:g+l*n.deviceSpacingY},data:{label:d,deviceType:t.type.name,entityId:t.id.local}}),a.push({id:`${c}-${u}`,source:c,target:u,type:`smoothstep`,style:{stroke:r.device,strokeWidth:1}})}),m.forEach((o,s)=>{let l=t.length+s,u=Math.floor(l/n.devicesPerColumn),d=l%n.devicesPerColumn,f=`failed-${e.id}-${o.entityId}`;i.push({id:f,type:`failed`,position:{x:_+u*n.deviceColumnSpacingX,y:g+d*n.deviceSpacingY},data:{label:o.entityId,reason:o.reason}}),a.push({id:`${c}-${f}`,source:c,target:f,type:`smoothstep`,style:{stroke:r.failed,strokeWidth:1,strokeDasharray:`5,5`}})}),u+=o});let d=Array.from(s.values()),f=l-(d.length-1)*120/2;return d.forEach((e,t)=>{let o=`fabric-${e.vendorId}`;i.push({id:o,type:`fabric`,position:{x:n.hubX+n.fabricOffsetX,y:f+t*120},data:{label:e.label,vendorId:e.vendorId}});for(let t of e.bridgeIds)a.push({id:`${o}-bridge-${t}`,source:o,target:`bridge-${t}`,type:`smoothstep`,animated:!0,style:{stroke:r.fabric,strokeWidth:1.5}})}),{nodes:i,edges:a}}var B0e=()=>{let{t:e}=Ts(),t=tv(),{content:n,isLoading:r}=FT(),i=nv(e=>e.devices.byBridge),[a,o,s]=s0e([]),[c,l,u]=c0e([]),[d,f]=(0,C.useState)(!1),{mode:p}=Pm(),m=p===`dark`,h=(0,C.useRef)([]),[g,_]=(0,C.useState)(!1);(0,C.useEffect)(()=>{t(J_())},[t]),(0,C.useEffect)(()=>{if(n)for(let e of n)t(BT(e.id))},[t,n]);let v=(0,C.useMemo)(()=>{let e={};if(n)for(let t of n)e[t.id]=i[t.id]?.content;return e},[n,i]),y=(0,C.useMemo)(()=>!n||n.length===0?!0:n.every(e=>i[e.id]?.isInitialized),[n,i]);(0,C.useEffect)(()=>{if(!n||!y)return;let e=z0e(n,v,{hubX:400,minBridgeSpacingY:200,deviceSpacingY:55,devicesPerColumn:10,deviceColumnSpacingX:220,fabricOffsetX:-350,bridgeOffsetX:250,deviceOffsetX:280},{running:m?`#81c784`:`#4caf50`,inactive:m?`#616161`:`#bdbdbd`,device:m?`#90caf9`:`#64b5f6`,failed:m?`#ef5350`:`#f44336`,fabric:m?`#ce93d8`:`#ab47bc`});try{let t=localStorage.getItem(`hamh-network-map-positions`);if(t){let n=JSON.parse(t);for(let t of e.nodes)n[t.id]&&(t.position=n[t.id])}}catch{}o(e.nodes),l(e.edges)},[n,v,y,o,l,m]);let b=(0,C.useCallback)(()=>{t(J_())},[t]),x=(0,C.useCallback)((e,t)=>{let n=a.find(e=>e.id===t.id);n&&(h.current.push({nodeId:t.id,position:{...n.position}}),_(!0));let r=`hamh-network-map-positions`;try{let e=localStorage.getItem(r),n=e?JSON.parse(e):{};n[t.id]={x:t.position.x,y:t.position.y},localStorage.setItem(r,JSON.stringify(n))}catch{}},[a]),S=(0,C.useCallback)(()=>{localStorage.removeItem(`hamh-network-map-positions`),h.current=[],_(!1),t(J_())},[t]),w=(0,C.useCallback)(()=>{let e=h.current.pop();if(!e)return;_(h.current.length>0),o(t=>t.map(t=>t.id===e.nodeId?{...t,position:e.position}:t));let t=`hamh-network-map-positions`;try{let n=localStorage.getItem(t),r=n?JSON.parse(n):{};r[e.nodeId]=e.position,localStorage.setItem(t,JSON.stringify(r))}catch{}},[o]),T=r||!y;return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2},children:[(0,G.jsxs)(Q,{variant:`h4`,sx:{display:`flex`,alignItems:`center`,gap:2},children:[(0,G.jsx)(WT,{}),e(`networkMap.title`)]}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:.5},children:[(0,G.jsx)(vb,{title:e(`networkMap.undoMove`),children:(0,G.jsx)(`span`,{children:(0,G.jsx)(Vh,{onClick:w,color:`primary`,disabled:!g,children:(0,G.jsx)(gge,{})})})}),(0,G.jsx)(vb,{title:e(`networkMap.resetLayout`),children:(0,G.jsx)(Vh,{onClick:S,color:`primary`,children:(0,G.jsx)(pE,{})})}),(0,G.jsx)(vb,{title:e(`networkMap.refreshData`),children:(0,G.jsx)(Vh,{onClick:b,color:`primary`,children:(0,G.jsx)(fE,{})})}),(0,G.jsx)(vb,{title:e(d?`networkMap.exitFullscreen`:`networkMap.fullscreen`),children:(0,G.jsx)(Vh,{onClick:()=>f(e=>!e),color:`primary`,children:d?(0,G.jsx)(Xhe,{}):(0,G.jsx)(Yhe,{})})})]})]}),T?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:8},children:(0,G.jsx)(zh,{})}):(0,G.jsx)(Z,{sx:{width:`100%`,height:d?`calc(100vh - 100px)`:600,border:`1px solid`,borderColor:`divider`,borderRadius:2,overflow:`hidden`,transition:`height 0.3s ease`},children:(0,G.jsxs)(o0e,{nodes:a,edges:c,onNodesChange:s,onEdgesChange:u,onNodeDragStop:x,nodeTypes:R0e,colorMode:m?`dark`:`light`,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(p0e,{variant:N7.Dots,gap:20,size:1}),(0,G.jsx)(b0e,{}),(0,G.jsx)(N0e,{nodeStrokeWidth:3,zoomable:!0,pannable:!0,nodeColor:e=>{switch(e.type){case`hub`:return`#1976d2`;case`bridge`:return`#4caf50`;case`fabric`:return`#9c27b0`;case`failed`:return`#f44336`;default:return m?`#90caf9`:`#90a4ae`}},style:{borderRadius:8}})]})}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:3,mt:2,flexWrap:`wrap`,alignItems:`center`},children:[(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,fontWeight:600,children:[e(`networkMap.legend`),`:`]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:`50%`,background:`linear-gradient(135deg, #7b1fa2, #9c27b0)`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.controller`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:`50%`,background:`linear-gradient(135deg, #1976d2, #1565c0)`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.hub`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:.5,background:m?`#1b3a1b`:`#e8f5e9`,border:`1px solid #4caf50`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.bridge`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:.5,background:m?`#2a2a2a`:`#fff`,border:`1px solid ${m?`#616161`:`#bdbdbd`}`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.device`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:.5,background:m?`#3a1515`:`#ffebee`,border:`1px dashed #f44336`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.failed`)})]})]})]})};function V0e(e){return Yd(`MuiTab`,e)}var B7=Xd(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`iconWrapper`,`icon`]),H0e=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e;return Tp({root:[`root`,a&&o&&`labelIcon`,`textColor${Y(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`iconWrapper`,`icon`]},V0e,t)},U0e=J(Ph,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${Y(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${B7.iconWrapper}`]:t.iconWrapper},{[`& .${B7.icon}`]:t.icon}]}})(Fm(({theme:e})=>({...e.typography.button,maxWidth:360,minWidth:90,position:`relative`,minHeight:48,flexShrink:0,padding:`12px 16px`,overflow:`hidden`,whiteSpace:`normal`,textAlign:`center`,lineHeight:1.25,variants:[{props:({ownerState:e})=>e.label&&(e.iconPosition===`top`||e.iconPosition===`bottom`),style:{flexDirection:`column`}},{props:({ownerState:e})=>e.label&&e.iconPosition!==`top`&&e.iconPosition!==`bottom`,style:{flexDirection:`row`}},{props:({ownerState:e})=>e.icon&&e.label,style:{minHeight:72,paddingTop:9,paddingBottom:9}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`top`,style:{[`& > .${B7.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${B7.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${B7.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${B7.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${B7.selected}`]:{opacity:1},[`&.${B7.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${B7.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${B7.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${B7.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${B7.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:({ownerState:e})=>e.fullWidth,style:{flexShrink:1,flexGrow:1,flexBasis:0,maxWidth:`none`}},{props:({ownerState:e})=>e.wrapped,style:{fontSize:e.typography.pxToRem(12)}}]}))),V7=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiTab`}),{className:r,disabled:i=!1,disableFocusRipple:a=!1,fullWidth:o,icon:s,iconPosition:c=`top`,indicator:l,label:u,onChange:d,onClick:f,onFocus:p,selected:m,selectionFollowsFocus:h,textColor:g=`inherit`,value:_,wrapped:v=!1,...y}=n,b={...n,disabled:i,disableFocusRipple:a,selected:m,icon:!!s,iconPosition:c,label:!!u,fullWidth:o,textColor:g,wrapped:v},x=H0e(b),S=s&&u&&C.isValidElement(s)?C.cloneElement(s,{className:K(x.icon,s.props.className)}):s;return(0,G.jsxs)(U0e,{focusRipple:!a,className:K(x.root,r),ref:t,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,_),f&&f(e)},onFocus:e=>{h&&!m&&d&&d(e,_),p&&p(e)},ownerState:b,tabIndex:m?0:-1,...y,children:[c===`top`||c===`start`?(0,G.jsxs)(C.Fragment,{children:[S,u]}):(0,G.jsxs)(C.Fragment,{children:[u,S]}),l]})});function W0e(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function G0e(e,t,n,r={},i=()=>{}){let{ease:a=W0e,duration:o=300}=r,s=null,c=t[e],l=!1,u=()=>{l=!0},d=r=>{if(l){i(Error(`Animation cancelled`));return}s===null&&(s=r);let u=Math.min(1,(r-s)/o);if(t[e]=a(u)*(n-c)+c,u>=1){requestAnimationFrame(()=>{i(null)});return}requestAnimationFrame(d)};return c===n?(i(Error(`Element already at target position`)),u):(requestAnimationFrame(d),u)}var K0e={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`};function q0e(e){let{onChange:t,...n}=e,r=C.useRef(),i=C.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return rh(()=>{let e=Xm(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=th(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),C.useEffect(()=>{a(),t(r.current)},[t]),(0,G.jsx)(`div`,{style:K0e,...n,ref:i})}var J0e=X((0,G.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Y0e=X((0,G.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function X0e(e){return Yd(`MuiTabScrollButton`,e)}var Z0e=Xd(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),Q0e=e=>{let{classes:t,orientation:n,disabled:r}=e;return Tp({root:[`root`,n,r&&`disabled`]},X0e,t)},$0e=J(Ph,{name:`MuiTabScrollButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.orientation&&t[n.orientation]]}})({width:40,flexShrink:0,opacity:.8,[`&.${Z0e.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),e2e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,u=Wf(),d={isRtl:u,...n},f=Q0e(d),p=i.StartScrollButtonIcon??J0e,m=i.EndScrollButtonIcon??Y0e,h=Xv({elementType:p,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:d}),g=Xv({elementType:m,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:d});return(0,G.jsx)($0e,{component:`div`,className:K(f.root,r),ref:t,role:null,ownerState:d,tabIndex:null,...l,style:{...l.style,...s===`vertical`&&{"--TabScrollButton-svgRotate":`rotate(${u?-90:90}deg)`}},children:o===`left`?(0,G.jsx)(p,{...h}):(0,G.jsx)(m,{...g})})});function t2e(e){return Yd(`MuiTabs`,e)}var H7=Xd(`MuiTabs`,[`root`,`vertical`,`list`,`flexContainer`,`flexContainerVertical`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),U7=(e,t)=>e===t?e.firstChild:t&&t.nextElementSibling?t.nextElementSibling:e.firstChild,W7=(e,t)=>e===t?e.lastChild:t&&t.previousElementSibling?t.previousElementSibling:e.lastChild,G7=(e,t,n)=>{let r=!1,i=n(e,t);for(;i;){if(i===e.firstChild){if(r)return;r=!0}let t=i.disabled||i.getAttribute(`aria-disabled`)===`true`;if(!i.hasAttribute(`tabindex`)||t)i=n(e,i);else{i.focus();return}}},n2e=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return Tp({root:[`root`,t&&`vertical`],scroller:[`scroller`,n&&`fixed`,r&&`hideScrollbar`,i&&`scrollableX`,a&&`scrollableY`],list:[`list`,`flexContainer`,t&&`flexContainerVertical`,t&&`vertical`,o&&`centered`],indicator:[`indicator`],scrollButtons:[`scrollButtons`,s&&`scrollButtonsHideMobile`],scrollableX:[i&&`scrollableX`],hideScrollbar:[r&&`hideScrollbar`]},t2e,c)},r2e=J(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${H7.scrollButtons}`]:t.scrollButtons},{[`& .${H7.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(Fm(({theme:e})=>({overflow:`hidden`,minHeight:48,WebkitOverflowScrolling:`touch`,display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.scrollButtonsHideMobile,style:{[`& .${H7.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),i2e=J(`div`,{name:`MuiTabs`,slot:`Scroller`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.scroller,n.fixed&&t.fixed,n.hideScrollbar&&t.hideScrollbar,n.scrollableX&&t.scrollableX,n.scrollableY&&t.scrollableY]}})({position:`relative`,display:`inline-block`,flex:`1 1 auto`,whiteSpace:`nowrap`,variants:[{props:({ownerState:e})=>e.fixed,style:{overflowX:`hidden`,width:`100%`}},{props:({ownerState:e})=>e.hideScrollbar,style:{scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}},{props:({ownerState:e})=>e.scrollableX,style:{overflowX:`auto`,overflowY:`hidden`}},{props:({ownerState:e})=>e.scrollableY,style:{overflowY:`auto`,overflowX:`hidden`}}]}),a2e=J(`div`,{name:`MuiTabs`,slot:`List`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.list,t.flexContainer,n.vertical&&t.flexContainerVertical,n.centered&&t.centered]}})({display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.centered,style:{justifyContent:`center`}}]}),o2e=J(`span`,{name:`MuiTabs`,slot:`Indicator`})(Fm(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,transition:e.transitions.create(),variants:[{props:{indicatorColor:`primary`},style:{backgroundColor:(e.vars||e).palette.primary.main}},{props:{indicatorColor:`secondary`},style:{backgroundColor:(e.vars||e).palette.secondary.main}},{props:({ownerState:e})=>e.vertical,style:{height:`100%`,width:2,right:0}}]}))),s2e=J(q0e)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),K7={},c2e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiTabs`}),r=wm(),i=Wf(),{"aria-label":a,"aria-labelledby":o,action:s,centered:c=!1,children:l,className:u,component:d=`div`,allowScrollButtonsMobile:f=!1,indicatorColor:p=`primary`,onChange:m,orientation:h=`horizontal`,ScrollButtonComponent:g,scrollButtons:_=`auto`,selectionFollowsFocus:v,slots:y={},slotProps:b={},TabIndicatorProps:x={},TabScrollButtonProps:S={},textColor:w=`primary`,value:T,variant:E=`standard`,visibleScrollbar:D=!1,...O}=n,k=E===`scrollable`,A=h===`vertical`,j=A?`scrollTop`:`scrollLeft`,M=A?`top`:`left`,N=A?`bottom`:`right`,P=A?`clientHeight`:`clientWidth`,F=A?`height`:`width`,I={...n,component:d,allowScrollButtonsMobile:f,indicatorColor:p,orientation:h,vertical:A,scrollButtons:_,textColor:w,variant:E,visibleScrollbar:D,fixed:!k,hideScrollbar:k&&!D,scrollableX:k&&!A,scrollableY:k&&A,centered:c&&!k,scrollButtonsHideMobile:!f},L=n2e(I),R=Xv({elementType:y.StartScrollButtonIcon,externalSlotProps:b.startScrollButtonIcon,ownerState:I}),ee=Xv({elementType:y.EndScrollButtonIcon,externalSlotProps:b.endScrollButtonIcon,ownerState:I}),[z,te]=C.useState(!1),[B,V]=C.useState(K7),[ne,re]=C.useState(!1),[ie,ae]=C.useState(!1),[oe,se]=C.useState(!1),[ce,le]=C.useState({overflow:`hidden`,scrollbarWidth:0}),ue=new Map,H=C.useRef(null),de=C.useRef(null),fe={slots:y,slotProps:{indicator:x,scrollButtons:S,...b}},U=()=>{let e=H.current,t;if(e){let n=e.getBoundingClientRect();t={clientWidth:e.clientWidth,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}let n;if(e&&T!==!1){let e=de.current.children;if(e.length>0){let t=e[ue.get(T)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},pe=ch(()=>{let{tabsMeta:e,tabMeta:t}=U(),n=0,r;A?(r=`top`,t&&e&&(n=t.top-e.top+e.scrollTop)):(r=i?`right`:`left`,t&&e&&(n=(i?-1:1)*(t[r]-e[r]+e.scrollLeft)));let a={[r]:n,[F]:t?t[F]:0};if(typeof B[r]!=`number`||typeof B[F]!=`number`)V(a);else{let e=Math.abs(B[r]-a[r]),t=Math.abs(B[F]-a[F]);(e>=1||t>=1)&&V(a)}}),me=(e,{animation:t=!0}={})=>{t?G0e(j,H.current,e,{duration:r.transitions.duration.standard}):H.current[j]=e},W=e=>{let t=H.current[j];A?t+=e:t+=e*(i?-1:1),me(t)},he=()=>{let e=H.current[P],t=0,n=Array.from(de.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[P]>e){r===0&&(t=e);break}t+=i[P]}return t},ge=()=>{W(-1*he())},_e=()=>{W(he())},[ve,{onChange:ye,...be}]=Um(`scrollbar`,{className:K(L.scrollableX,L.hideScrollbar),elementType:s2e,shouldForwardComponentProp:!0,externalForwardedProps:fe,ownerState:I}),xe=C.useCallback(e=>{ye?.(e),le({overflow:null,scrollbarWidth:e})},[ye]),[Se,Ce]=Um(`scrollButtons`,{className:K(L.scrollButtons,S.className),elementType:e2e,externalForwardedProps:fe,ownerState:I,additionalProps:{orientation:h,slots:{StartScrollButtonIcon:y.startScrollButtonIcon||y.StartScrollButtonIcon,EndScrollButtonIcon:y.endScrollButtonIcon||y.EndScrollButtonIcon},slotProps:{startScrollButtonIcon:R,endScrollButtonIcon:ee}}}),we=()=>{let e={};e.scrollbarSizeListener=k?(0,G.jsx)(ve,{...be,onChange:xe}):null;let t=k&&(_===`auto`&&(ne||ie)||_===!0);return e.scrollButtonStart=t?(0,G.jsx)(Se,{direction:i?`right`:`left`,onClick:ge,disabled:!ne,...Ce}):null,e.scrollButtonEnd=t?(0,G.jsx)(Se,{direction:i?`left`:`right`,onClick:_e,disabled:!ie,...Ce}):null,e},Te=ch(e=>{let{tabsMeta:t,tabMeta:n}=U();!n||!t||(n[M]<t[M]?me(t[j]+(n[M]-t[M]),{animation:e}):n[N]>t[N]&&me(t[j]+(n[N]-t[N]),{animation:e}))}),Ee=ch(()=>{k&&_!==!1&&se(!oe)});C.useEffect(()=>{let e=Xm(()=>{H.current&&pe()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),Ee()},r=th(H.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(de.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(de.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[pe,Ee]),C.useEffect(()=>{let e=Array.from(de.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&k&&_!==!1){let n=e[0],r=e[t-1],i={root:H.current,threshold:.99},a=new IntersectionObserver(e=>{re(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{ae(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[k,_,oe,l?.length]),C.useEffect(()=>{te(!0)},[]),C.useEffect(()=>{pe()}),C.useEffect(()=>{Te(K7!==B)},[Te,B]),C.useImperativeHandle(s,()=>({updateIndicator:pe,updateScrollButtons:Ee}),[pe,Ee]);let[De,Oe]=Um(`indicator`,{className:K(L.indicator,x.className),elementType:o2e,externalForwardedProps:fe,ownerState:I,additionalProps:{style:B}}),ke=(0,G.jsx)(De,{...Oe}),Ae=0,je=C.Children.map(l,e=>{if(!C.isValidElement(e))return null;let t=e.props.value===void 0?Ae:e.props.value;ue.set(t,Ae);let n=t===T;return Ae+=1,C.cloneElement(e,{fullWidth:E===`fullWidth`,indicator:n&&!z&&ke,selected:n,selectionFollowsFocus:v,onChange:m,textColor:w,value:t,...Ae===1&&T===!1&&!e.props.tabIndex?{tabIndex:0}:{}})}),Me=e=>{if(e.altKey||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=de.current,n=Lb($m(t));if(n?.getAttribute(`role`)!==`tab`)return;let r=h===`horizontal`?`ArrowLeft`:`ArrowUp`,a=h===`horizontal`?`ArrowRight`:`ArrowDown`;switch(h===`horizontal`&&i&&(r=`ArrowRight`,a=`ArrowLeft`),e.key){case r:e.preventDefault(),G7(t,n,W7);break;case a:e.preventDefault(),G7(t,n,U7);break;case`Home`:e.preventDefault(),G7(t,null,U7);break;case`End`:e.preventDefault(),G7(t,null,W7);break;default:break}},Ne=we(),[Pe,Fe]=Um(`root`,{ref:t,className:K(L.root,u),elementType:r2e,externalForwardedProps:{...fe,...O,component:d},ownerState:I}),[Ie,Le]=Um(`scroller`,{ref:H,className:L.scroller,elementType:i2e,externalForwardedProps:fe,ownerState:I,additionalProps:{style:{overflow:ce.overflow,[A?`margin${i?`Left`:`Right`}`:`marginBottom`]:D?void 0:-ce.scrollbarWidth}}}),[Re,ze]=Um(`list`,{ref:de,className:K(L.list,L.flexContainer),elementType:a2e,externalForwardedProps:fe,ownerState:I,getSlotProps:e=>({...e,onKeyDown:t=>{Me(t),e.onKeyDown?.(t)}})});return(0,G.jsxs)(Pe,{...Fe,children:[Ne.scrollButtonStart,Ne.scrollbarSizeListener,(0,G.jsxs)(Ie,{...Le,children:[(0,G.jsx)(Re,{"aria-label":a,"aria-labelledby":o,"aria-orientation":h===`vertical`?`vertical`:null,role:`tablist`,...ze,children:je}),z&&ke]}),Ne.scrollButtonEnd]})});async function q7(e,t){let n=await fetch(e,t);if(!n.ok)throw Error(`${n.status} ${n.statusText}`);return n.json()}var l2e=()=>{let[e,t]=(0,C.useState)([]),[n,r]=(0,C.useState)([]),[i,a]=(0,C.useState)(!0),[o,s]=(0,C.useState)(),[c,l]=(0,C.useState)(!1),[u,d]=(0,C.useState)(0),[f,p]=(0,C.useState)(``),[m,h]=(0,C.useState)(``),[g,_]=(0,C.useState)(null),[v,y]=(0,C.useState)(!1),b=(0,C.useRef)(null),x=(0,C.useCallback)(async()=>{a(!0),s(void 0);try{let[e,n]=await Promise.all([q7(`api/plugins`),q7(`api/plugins/installed`)]);t(e),r(n)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,C.useEffect)(()=>{x()},[x]);let S=async()=>{if(f.trim()){y(!0);try{await q7(`api/plugins/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({packageName:f.trim()})}),p(``),l(!1),await x()}catch(e){s(e instanceof Error?e.message:String(e))}finally{y(!1)}}},w=async()=>{if(g){y(!0);try{let e=await g.arrayBuffer(),t=await fetch(`api/plugins/upload`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`${t.status} ${t.statusText}`)}_(null),b.current&&(b.current.value=``),l(!1),await x()}catch(e){s(e instanceof Error?e.message:String(e))}finally{y(!1)}}},T=async()=>{if(m.trim()){y(!0);try{await q7(`api/plugins/install-local`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:m.trim()})}),h(``),l(!1),await x()}catch(e){s(e instanceof Error?e.message:String(e))}finally{y(!1)}}},E=async e=>{try{await q7(`api/plugins/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({packageName:e})}),await x()}catch(e){s(e instanceof Error?e.message:String(e))}},D=async(e,t,n)=>{try{await q7(`api/plugins/${e}/${t}/${n}`,{method:`POST`}),await x()}catch(e){s(e instanceof Error?e.message:String(e))}};if(i)return(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,py:6},children:(0,G.jsx)(zh,{})});let O=e.reduce((e,t)=>e+t.plugins.length,0);return(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:3,p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsxs)(Q,{variant:`h5`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(nE,{}),` Plugins`]}),(0,G.jsxs)(Yv,{direction:`row`,spacing:1,children:[(0,G.jsx)(vb,{title:`Refresh`,children:(0,G.jsx)(Vh,{onClick:x,children:(0,G.jsx)(fE,{})})}),(0,G.jsx)(xv,{variant:`contained`,startIcon:(0,G.jsx)(yb,{}),onClick:()=>l(!0),size:`small`,children:`Install Plugin`})]})]}),o&&(0,G.jsx)(Wh,{severity:`error`,onClose:()=>s(void 0),children:o}),O===0&&n.length===0&&(0,G.jsx)(Wh,{severity:`info`,children:`No plugins installed. Click "Install Plugin" to add an npm plugin package, or plugins will appear here when registered by the bridge.`}),n.length>0&&(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`h6`,gutterBottom:!0,children:`Installed Packages`}),(0,G.jsx)(oy,{dense:!0,children:n.map(e=>(0,G.jsxs)(ly,{secondaryAction:(0,G.jsx)(vb,{title:`Uninstall`,children:(0,G.jsx)(Vh,{edge:`end`,onClick:()=>E(e.packageName),color:`error`,size:`small`,children:(0,G.jsx)(RS,{})})}),children:[(0,G.jsx)(dy,{children:(0,G.jsx)(nE,{})}),(0,G.jsx)(py,{primary:e.packageName,secondary:`v${e.version}, installed ${new Date(e.installedAt).toLocaleDateString()}`})]},e.packageName))})]})}),e.map(e=>(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`h6`,gutterBottom:!0,children:e.bridgeName}),e.plugins.length===0?(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:`No active plugins on this bridge.`}):(0,G.jsx)(oy,{dense:!0,children:e.plugins.map(t=>(0,G.jsxs)(Z,{children:[(0,G.jsxs)(ly,{secondaryAction:(0,G.jsxs)(Yv,{direction:`row`,spacing:.5,children:[t.circuitBreaker?.disabled&&(0,G.jsx)(vb,{title:`Reset circuit breaker`,children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>D(e.bridgeId,t.name,`reset`),children:(0,G.jsx)(pE,{})})}),(0,G.jsx)(vb,{title:t.enabled?`Disable`:`Enable`,children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>D(e.bridgeId,t.name,t.enabled?`disable`:`enable`),children:t.enabled?(0,G.jsx)(oge,{}):(0,G.jsx)(age,{})})})]}),children:[(0,G.jsx)(dy,{children:(0,G.jsx)(nE,{color:t.enabled?`primary`:`disabled`})}),(0,G.jsx)(py,{primary:(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[t.name,(0,G.jsx)(Nv,{label:`v${t.version}`,size:`small`,variant:`outlined`}),t.source===`builtin`&&(0,G.jsx)(Nv,{label:`built-in`,size:`small`}),!t.enabled&&(0,G.jsx)(Nv,{label:`disabled`,size:`small`,color:`warning`}),t.circuitBreaker?.disabled&&(0,G.jsx)(Nv,{label:`circuit breaker open`,size:`small`,color:`error`})]}),secondary:t.devices.length>0?`${t.devices.length} device(s)`:`No devices registered`})]}),t.circuitBreaker?.disabled&&t.circuitBreaker.lastError&&(0,G.jsx)(Wh,{severity:`error`,sx:{mx:2,mb:1},children:t.circuitBreaker.lastError}),t.devices.length>0&&(0,G.jsx)(oy,{dense:!0,sx:{pl:6},children:t.devices.map(e=>(0,G.jsx)(ly,{children:(0,G.jsx)(py,{primary:e.name,secondary:`${e.deviceType}, ${e.id}`})},e.id))}),(0,G.jsx)(Xb,{})]},t.name))})]})},e.bridgeId)),(0,G.jsxs)(Gb,{open:c,onClose:()=>l(!1),maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Jb,{children:`Install Plugin`}),(0,G.jsxs)(qb,{children:[(0,G.jsxs)(c2e,{value:u,onChange:(e,t)=>d(t),sx:{mb:2},children:[(0,G.jsx)(V7,{label:`npm`}),(0,G.jsx)(V7,{label:`Upload .tgz`}),(0,G.jsx)(V7,{label:`Local Path`})]}),u===0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(OS,{autoFocus:!0,margin:`dense`,label:`npm package name`,placeholder:`e.g. hamh-plugin-example`,fullWidth:!0,value:f,onChange:e=>p(e.target.value),disabled:v,onKeyDown:e=>{e.key===`Enter`&&S()}}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:`The plugin will be installed via npm. After installation, restart the bridge to load the plugin.`})]}),u===1&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(xv,{variant:`outlined`,component:`label`,startIcon:(0,G.jsx)(CE,{}),fullWidth:!0,sx:{mt:1},disabled:v,children:[g?g.name:`Choose .tgz file`,(0,G.jsx)(`input`,{ref:b,type:`file`,accept:`.tgz,application/gzip`,hidden:!0,onChange:e=>_(e.target.files?.[0]??null)})]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:`Upload a packaged plugin (.tgz). Restart the bridge after installation.`})]}),u===2&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(OS,{autoFocus:!0,margin:`dense`,label:`Absolute path to plugin folder`,placeholder:`/path/to/your/plugin`,fullWidth:!0,value:m,onChange:e=>h(e.target.value),disabled:v,InputProps:{startAdornment:(0,G.jsx)(Jhe,{sx:{mr:1}})},onKeyDown:e=>{e.key===`Enter`&&T()}}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:`Link a local plugin directory (creates a symlink). Useful for development. Restart the bridge after linking.`})]})]}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>l(!1),disabled:v,children:`Cancel`}),u===0&&(0,G.jsx)(xv,{onClick:S,variant:`contained`,disabled:v||!f.trim(),children:v?(0,G.jsx)(zh,{size:20}):`Install`}),u===1&&(0,G.jsx)(xv,{onClick:w,variant:`contained`,disabled:v||!g,children:v?(0,G.jsx)(zh,{size:20}):`Upload`}),u===2&&(0,G.jsx)(xv,{onClick:T,variant:`contained`,disabled:v||!m.trim(),children:v?(0,G.jsx)(zh,{size:20}):`Link`})]})]})]})};async function u2e(){let e=await fetch(`api/settings/auth`);return await z_(e,`Failed to fetch auth settings`),R_(e)}async function d2e(e,t){let n=await fetch(`api/settings/auth`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})});return await z_(n,`Failed to update auth settings`),R_(n)}async function f2e(){let e=await fetch(`api/settings/auth`,{method:`DELETE`});return await z_(e,`Failed to delete auth settings`),R_(e)}async function p2e(){let e=await fetch(`api/settings/recovery`);return await z_(e,`Failed to fetch recovery settings`),R_(e)}async function m2e(e){let t=await fetch(`api/settings/recovery`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return await z_(t,`Failed to update recovery settings`),R_(t)}var h2e=()=>{let{t:e}=Ts(),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(null),s=(0,C.useCallback)(async()=>{i(!0),o(null);try{let t=await fetch(`api/system/update-check`);t.ok?n(await t.json()):t.status===404?o(e(`updateChecker.notAvailable`)):o(e(`updateChecker.checkFailed`))}catch{o(e(`updateChecker.unreachable`))}finally{i(!1)}},[e]);return(0,C.useEffect)(()=>{s()},[s]),(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2},children:[(0,G.jsxs)(Q,{variant:`h6`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(ige,{}),e(`updateChecker.title`)]}),(0,G.jsx)(xv,{size:`small`,startIcon:r?(0,G.jsx)(zh,{size:16}):(0,G.jsx)(fE,{}),onClick:s,disabled:r,children:e(`updateChecker.checkNow`)})]}),a&&(0,G.jsx)(Wh,{severity:`warning`,sx:{mb:2},children:a}),t&&(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[e(`updateChecker.currentVersion`),`:`]}),(0,G.jsx)(Nv,{label:t.currentVersion,size:`small`,color:`primary`})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[e(`updateChecker.latestVersion`),`:`]}),(0,G.jsx)(Nv,{label:t.latestVersion,size:`small`,color:t.updateAvailable?`warning`:`success`})]}),t.updateAvailable?(0,G.jsxs)(Wh,{severity:`info`,action:(0,G.jsx)(xv,{color:`inherit`,size:`small`,endIcon:(0,G.jsx)(lE,{}),href:t.releaseUrl,target:`_blank`,rel:`noopener noreferrer`,children:e(`updateChecker.releaseNotes`)}),children:[(0,G.jsx)(Q,{variant:`body2`,sx:{fontWeight:600},children:e(`updateChecker.updateAvailable`)}),(0,G.jsx)(Q,{variant:`body2`,children:(t=>{switch(t){case`Home Assistant Add-on`:return e(`updateChecker.instructionAddon`);case`Docker`:return e(`updateChecker.instructionDocker`);default:return e(`updateChecker.instructionNpm`)}})(t.environment)})]}):(0,G.jsx)(Wh,{severity:`success`,children:e(`updateChecker.upToDate`)}),t.releaseNotes&&t.updateAvailable&&(0,G.jsx)(Z,{sx:{p:1.5,borderRadius:1,bgcolor:`action.hover`,maxHeight:120,overflow:`auto`},children:(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{whiteSpace:`pre-wrap`},children:t.releaseNotes})})]})]})})},J7=10,Y7=3600,g2e=()=>{let{t:e}=Ts(),[t,n]=(0,C.useState)(!1),[r,i]=(0,C.useState)(60),[a,o]=(0,C.useState)(!0),[s,c]=(0,C.useState)(!1),[l,u]=(0,C.useState)(null);return(0,C.useEffect)(()=>{p2e().then(e=>{n(e.autoRecoveryEnabled),i(Math.round(e.recoveryIntervalMs/1e3))}).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>o(!1))},[]),(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`h6`,sx:{mb:2},children:e(`settings.recovery.title`,`Auto recovery`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`settings.recovery.hint`,`Periodically restarts bridges that failed to start. Only failed bridges are touched.`)}),l&&(0,G.jsx)(Wh,{severity:`error`,sx:{mb:2},children:l}),a?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:2},children:(0,G.jsx)(zh,{})}):(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,G.jsx)(Vv,{control:(0,G.jsx)(qS,{checked:t,onChange:e=>n(e.target.checked)}),label:e(`settings.recovery.enabled`,`Enabled`)}),(0,G.jsx)(OS,{type:`number`,size:`small`,label:e(`settings.recovery.interval`,`Interval (seconds)`),value:r,disabled:!t,onChange:e=>i(Number(e.target.value)),slotProps:{htmlInput:{min:J7,max:Y7}},sx:{maxWidth:220}}),(0,G.jsx)(Z,{children:(0,G.jsx)(xv,{variant:`contained`,onClick:async()=>{c(!0),u(null);try{let e=await m2e({autoRecoveryEnabled:t,recoveryIntervalMs:r*1e3});n(e.autoRecoveryEnabled),i(Math.round(e.recoveryIntervalMs/1e3))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}},disabled:s||Number.isNaN(r)||r<J7||r>Y7,children:e(`common.save`,`Save`)})})]})]})})},_2e=()=>{let{t:e}=Ts(),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!0),[a,o]=(0,C.useState)(!1),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(``),[p,m]=(0,C.useState)(``),h=(0,C.useCallback)(async()=>{i(!0);try{let e=await u2e();n(e),e.username&&f(e.username),c(null)}catch(t){c(t instanceof Error?t.message:e(`settings.authLoadFailed`))}finally{i(!1)}},[e]);(0,C.useEffect)(()=>{h()},[h]);let g=async()=>{if(!d.trim()||!p.trim()){c(e(`settings.usernamePasswordRequired`));return}o(!0),c(null),u(null);try{n(await d2e(d.trim(),p)),m(``),u(`Authentication enabled. The browser will prompt you to log in on the next request.`)}catch(t){c(t instanceof Error?t.message:e(`settings.authSaveFailed`))}finally{o(!1)}},[_,v]=(0,C.useState)(!1),y=async()=>{v(!1),o(!0),c(null),u(null);try{n(await f2e()),f(``),m(``),u(e(`settings.authDisabled`))}catch(t){c(t instanceof Error?t.message:e(`settings.authRemoveFailed`))}finally{o(!1)}},b=t?.source===`environment`;return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,sx:{mb:3},children:[(0,G.jsx)(MT,{sx:{mr:1,verticalAlign:`middle`}}),e(`settings.title`)]}),(0,G.jsx)(r4,{}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsx)(h2e,{}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsx)(g2e,{}),(0,G.jsx)(Xb,{sx:{my:3}}),r?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(zh,{})}):(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:2},children:[(0,G.jsx)(_E,{sx:{mr:1,verticalAlign:`middle`,fontSize:20}}),e(`settings.title`)]}),b&&(0,G.jsxs)(Wh,{severity:`info`,sx:{mb:2},children:[`Authentication is configured via environment variables (`,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_USERNAME`}),` /`,` `,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_PASSWORD`}),`). Remove the environment variables to manage authentication from here.`]}),s&&(0,G.jsx)(Wh,{severity:`error`,sx:{mb:2},children:s}),l&&(0,G.jsx)(Wh,{severity:`success`,sx:{mb:2},children:l}),t?.enabled&&!b&&(0,G.jsxs)(Wh,{severity:`info`,sx:{mb:2},children:[`Authentication is currently enabled for user "`,t.username,`". Enter a new password to change it, or remove authentication entirely.`]}),(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,maxWidth:400},children:[(0,G.jsx)(OS,{label:e(`settings.username`),value:d,onChange:e=>f(e.target.value),disabled:b||a,fullWidth:!0,size:`small`}),(0,G.jsx)(OS,{label:e(`settings.password`),type:`password`,value:p,onChange:e=>m(e.target.value),disabled:b||a,fullWidth:!0,size:`small`,placeholder:t?.enabled&&!b?e(`settings.enterNewPassword`):``}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:1},children:[(0,G.jsx)(xv,{variant:`contained`,onClick:g,disabled:b||a||!d.trim()||!p.trim(),startIcon:a?(0,G.jsx)(zh,{size:16}):(0,G.jsx)(hE,{}),children:t?.enabled&&!b?e(`common.update`):e(`settings.enableAuth`)}),t?.enabled&&!b&&(0,G.jsx)(xv,{variant:`outlined`,color:`error`,onClick:()=>v(!0),disabled:a,startIcon:(0,G.jsx)(RS,{}),children:e(`common.disabled`)})]})]}),(0,G.jsxs)(Wh,{severity:`warning`,sx:{mt:3},children:[`If you get locked out, delete the settings from the storage directory or set `,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_USERNAME`}),` /`,` `,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_PASSWORD`}),` environment variables in your Docker Compose file to regain access.`]})]})}),(0,G.jsx)(VT,{open:_,title:e(`settings.disableAuth`),message:e(`settings.disableAuthMessage`),confirmLabel:e(`settings.disableAuthConfirm`),confirmColor:`error`,onConfirm:y,onCancel:()=>v(!1)})]})};function v2e(e){let t=e.filter?.include??[];if(t.length!==0)return t.map(e=>e.type===ov.Pattern?e.value:`${e.type}: ${e.value}`).join(`, `)}var X7=/^[a-z0-9_]+\.[a-z0-9_]+$/,y2e=10;function Z7(e){return e?.message}var b2e=()=>{let{t:e}=Ts(),t=ey(),n=tv(),{content:r,isLoading:i}=FT(),a=RT(),o=zT(),[s,c]=(0,C.useState)(!1),[l,u]=(0,C.useState)(``),d=(0,C.useRef)(0),[f,p]=(0,C.useState)([{key:0,value:``}]),[m,h]=(0,C.useState)(!1),[g,_]=(0,C.useState)(null),v=f.map(e=>e.value.trim()),y=v.filter(e=>e!==``),b=e=>{let t=v[e];return t===``?!1:X7.test(t)?v.indexOf(t)!==e:!0},x=y.length>0&&f.every((e,t)=>!b(t)),S=(r??[]).filter(e=>e.featureFlags?.serverMode===!0),w=(0,C.useCallback)(async()=>{let r=l.trim(),i=f.map(e=>e.value.trim()).filter(e=>e!==``);if(!(!r||i.length===0||i.some(e=>!X7.test(e))||new Set(i).size!==i.length)){h(!0);try{await a({name:r,filter:{include:i.map(e=>({type:ov.Pattern,value:e})),exclude:[]},featureFlags:{serverMode:!0}}),t.show({message:e(`standaloneDevices.created`,`Standalone device created`),severity:`success`}),c(!1),u(``),p([{key:0,value:``}]),n(J_())}catch(n){t.show({message:Z7(n)??e(`standaloneDevices.createFailed`,`Could not create device`),severity:`error`})}finally{h(!1)}}},[l,f,a,t,e,n]),T=(0,C.useCallback)(async r=>{try{await o(r.id),t.show({message:e(`standaloneDevices.deleted`,`Standalone device deleted`),severity:`success`}),n(J_())}catch(n){t.show({message:Z7(n)??e(`standaloneDevices.deleteFailed`,`Could not delete device`),severity:`error`})}},[o,t,e,n]);return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,mb:1},children:[(0,G.jsx)(Q,{variant:`h5`,component:`h1`,children:e(`standaloneDevices.title`,`Standalone Devices`)}),(0,G.jsx)(xv,{variant:`contained`,startIcon:(0,G.jsx)(yb,{}),onClick:()=>c(!0),children:e(`standaloneDevices.create`,`Add device`)})]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`standaloneDevices.subtitle`,`Each device runs on its own Matter node with its own pairing code, instead of inside a bridge.`)}),i&&!r?(0,G.jsx)(zh,{}):S.length===0?(0,G.jsx)(Wh,{severity:`info`,children:e(`standaloneDevices.empty`,`No standalone devices yet. Add one to expose a single entity as its own Matter device.`)}):(0,G.jsx)(Yv,{spacing:1,children:S.map(t=>(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:2},children:[(0,G.jsxs)(Z,{sx:{minWidth:0},children:[(0,G.jsx)(Q,{variant:`subtitle1`,noWrap:!0,children:t.name}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:v2e(t)??e(`standaloneDevices.noEntity`,`no entity`)})]}),(0,G.jsxs)(Yv,{direction:`row`,spacing:1,alignItems:`center`,children:[(t.failedEntities?.length??0)>0&&(0,G.jsx)(vb,{title:t.failedEntities?.map(e=>e.reason).join(` `)??``,children:(0,G.jsx)(Nv,{size:`small`,color:`warning`,label:e(`standaloneDevices.entityProblem`,`entity problem`)})}),(0,G.jsx)(kx,{status:t.status,reason:t.statusReason}),(0,G.jsx)(vb,{title:e(`standaloneDevices.openBridge`,`Open details and pairing`),children:(0,G.jsx)(Vh,{component:da,to:Y9.bridge(t.id),size:`small`,children:(0,G.jsx)($he,{fontSize:`small`})})}),(0,G.jsx)(vb,{title:e(`common.delete`,`Delete`),children:(0,G.jsx)(Vh,{onClick:()=>_(t),size:`small`,color:`error`,children:(0,G.jsx)(eE,{fontSize:`small`})})})]})]})},t.id))}),(0,G.jsxs)(Gb,{open:s,onClose:()=>{m||c(!1)},fullWidth:!0,maxWidth:`sm`,children:[(0,G.jsx)(Jb,{children:e(`standaloneDevices.create`,`Add device`)}),(0,G.jsxs)(qb,{children:[(0,G.jsx)(OS,{label:e(`standaloneDevices.name`,`Name`),value:l,onChange:e=>u(e.target.value),fullWidth:!0,margin:`normal`,slotProps:{htmlInput:{maxLength:32}}}),f.map((t,n)=>(0,G.jsxs)(Z,{sx:{display:`flex`,gap:1,alignItems:`flex-start`},children:[(0,G.jsx)(Z,{sx:{flexGrow:1},children:(0,G.jsx)(ZS,{value:t.value,onChange:e=>{p(n=>n.map(n=>n.key===t.key?{...n,value:e}:n))},label:n===0?e(`standaloneDevices.entity`,`Entity`):e(`standaloneDevices.additionalEntity`,`Additional entity`),helperText:b(n)?e(`standaloneDevices.entityInvalid`,`Enter a single entity id like vacuum.living_room, wildcards are not allowed.`):n===0?e(`standaloneDevices.entityHelp`,`Pick the Home Assistant entity to expose.`):void 0})}),f.length>1&&(0,G.jsx)(Vh,{size:`small`,sx:{mt:3},onClick:()=>p(e=>e.filter(e=>e.key!==t.key)),children:(0,G.jsx)(eE,{fontSize:`small`})})]},t.key)),(0,G.jsx)(xv,{size:`small`,startIcon:(0,G.jsx)(yb,{}),disabled:f.length>=y2e,onClick:()=>{d.current+=1,p(e=>[...e,{key:d.current,value:``}])},children:e(`standaloneDevices.addEntity`,`Add another entity`)}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:1},children:e(`standaloneDevices.multiHint`,`The first entity is the primary and names the device. More than one entity per device is experimental.`)})]}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>c(!1),disabled:m,children:e(`common.cancel`,`Cancel`)}),(0,G.jsx)(xv,{onClick:w,variant:`contained`,disabled:m||!l.trim()||!x,children:m?e(`standaloneDevices.creating`,`Creating`):e(`common.create`,`Create`)})]})]}),(0,G.jsx)(VT,{open:g!==null,title:e(`standaloneDevices.confirmDeleteTitle`,`Delete standalone device`),message:e(`standaloneDevices.confirmDeleteMessage`,`This deletes the device's Matter node and unpairs it from your controllers. This cannot be undone.`),confirmLabel:e(`common.delete`,`Delete`),cancelLabel:e(`common.cancel`,`Cancel`),confirmColor:`error`,onConfirm:()=>{let e=g;_(null),e&&T(e)},onCancel:()=>_(null)})]})};function x2e(){var e=[...arguments];return(0,C.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var Q7=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function $7(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function e9(e){return`nodeType`in e}function t9(e){return e?$7(e)?e:e9(e)?e.ownerDocument?.defaultView??window:window:window}function n9(e){let{Document:t}=t9(e);return e instanceof t}function r9(e){return $7(e)?!1:e instanceof t9(e).HTMLElement}function i9(e){return e instanceof t9(e).SVGElement}function a9(e){return e?$7(e)?e.document:e9(e)?n9(e)?e:r9(e)||i9(e)?e.ownerDocument:document:document:document}var o9=Q7?C.useLayoutEffect:C.useEffect;function s9(e){let t=(0,C.useRef)(e);return o9(()=>{t.current=e}),(0,C.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function S2e(){let e=(0,C.useRef)(null);return[(0,C.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,C.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function c9(e,t){t===void 0&&(t=[e]);let n=(0,C.useRef)(e);return o9(()=>{n.current!==e&&(n.current=e)},t),n}function l9(e,t){let n=(0,C.useRef)();return(0,C.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function u9(e){let t=s9(e),n=(0,C.useRef)(null);return[n,(0,C.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function d9(e){let t=(0,C.useRef)();return(0,C.useEffect)(()=>{t.current=e},[e]),t.current}var f9={};function p9(e,t){return(0,C.useMemo)(()=>{if(t)return t;let n=f9[e]==null?0:f9[e]+1;return f9[e]=n,e+`-`+n},[e,t])}function C2e(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var m9=C2e(1),h9=C2e(-1);function w2e(e){return`clientX`in e&&`clientY`in e}function g9(e){if(!e)return!1;let{KeyboardEvent:t}=t9(e.target);return t&&e instanceof t}function T2e(e){if(!e)return!1;let{TouchEvent:t}=t9(e.target);return t&&e instanceof t}function _9(e){if(T2e(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return w2e(e)?{x:e.clientX,y:e.clientY}:null}var v9=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[v9.Translate.toString(e),v9.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),E2e=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function D2e(e){return e.matches(E2e)?e:e.querySelector(E2e)}var O2e={display:`none`};function k2e(e){let{id:t,value:n}=e;return C.createElement(`div`,{id:t,style:O2e},n)}function A2e(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return C.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function j2e(){let[e,t]=(0,C.useState)(``);return{announce:(0,C.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var M2e=(0,C.createContext)(null);function N2e(e){let t=(0,C.useContext)(M2e);(0,C.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function P2e(){let[e]=(0,C.useState)(()=>new Set),t=(0,C.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,C.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var F2e={draggable:`
465
+ M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}R7.displayName=`MiniMap`;var N0e=(0,C.memo)(R7),P0e=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,F0e={[a5.Line]:`right`,[a5.Handle]:`bottom-right`};function I0e({nodeId:e,position:t,variant:n=a5.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=$5(),y=typeof e==`string`?e:v,b=y5(),x=(0,C.useRef)(null),S=n===a5.Handle,w=v5((0,C.useCallback)(P0e(S&&p),[S,p]),h5),T=(0,C.useRef)(null),E=t??F0e[n];return(0,C.useEffect)(()=>{if(!(!x.current||!y))return T.current||=_$e({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=H8([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...f8({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{T.current?.destroy()}},[E,s,c,l,u,d,h,g,_,m]),(0,G.jsx)(`div`,{className:b4([`react-flow__resize-control`,`nodrag`,...E.split(`-`),n,r]),ref:x,style:{...i,scale:w,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,C.memo)(I0e);function L0e(e){return{running:{color:e?`#81c784`:`#2e7d32`,bg:e?`#1b3a1b`:`#e8f5e9`,border:`#4caf50`,Icon:gv},starting:{color:e?`#ffb74d`:`#ed6c02`,bg:e?`#3a2a10`:`#fff3e0`,border:`#ff9800`,Icon:Zhe},stopped:{color:e?`#bdbdbd`:`#757575`,bg:e?`#2a2a2a`:`#f5f5f5`,border:e?`#616161`:`#bdbdbd`,Icon:uge},failed:{color:e?`#ef5350`:`#d32f2f`,bg:e?`#3a1515`:`#ffebee`,border:`#f44336`,Icon:Ox}}}var R0e={hub:({data:e})=>{let{label:t,bridgeCount:n,deviceCount:r}=e,i=wm(),a=i.palette.primary.main,o=i.palette.primary.dark;return(0,G.jsxs)(Z,{sx:{background:`linear-gradient(135deg, ${a}, ${o})`,borderRadius:`50%`,width:120,height:120,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,color:i.palette.primary.contrastText,boxShadow:`0 4px 20px ${i.palette.mode===`dark`?`rgba(0,0,0,0.5)`:`rgba(25,118,210,0.4)`}`,border:`3px solid rgba(255,255,255,0.3)`},children:[(0,G.jsx)(aE,{sx:{fontSize:32,mb:.5}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:700,lineHeight:1.1,children:t}),(0,G.jsxs)(Q,{variant:`caption`,sx:{opacity:.8,fontSize:`0.65rem`},children:[n,` bridges · `,r,` devices`]}),(0,G.jsx)(e7,{type:`source`,position:P6.Right,style:{opacity:0}}),(0,G.jsx)(e7,{type:`source`,position:P6.Left,style:{opacity:0},id:`left`}),(0,G.jsx)(e7,{type:`source`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsx)(e7,{type:`source`,position:P6.Bottom,style:{opacity:0},id:`bottom`})]})},bridge:({data:e})=>{let{label:t,status:n,port:r,deviceCount:i,failedCount:a,fabricCount:o}=e,{mode:s}=Pm(),c=L0e(s===`dark`),l=c[n]??c.stopped,{Icon:u}=l;return(0,G.jsxs)(Z,{sx:{background:l.bg,border:`2px solid ${l.border}`,borderRadius:2,px:2,py:1.5,minWidth:180,maxWidth:220,boxShadow:`0 2px 12px rgba(0,0,0,0.08)`},children:[(0,G.jsx)(e7,{type:`target`,position:P6.Left,style:{opacity:0}}),(0,G.jsx)(e7,{type:`target`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsx)(e7,{type:`source`,position:P6.Right,style:{opacity:0}}),(0,G.jsx)(e7,{type:`source`,position:P6.Bottom,style:{opacity:0},id:`bottom`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5,mb:.5},children:[(0,G.jsx)(u,{sx:{fontSize:16,color:l.color}}),(0,G.jsx)(Q,{variant:`subtitle2`,fontWeight:700,noWrap:!0,sx:{color:l.color},children:t})]}),(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,children:[`Port `,r]}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:.5,mt:.5,flexWrap:`wrap`},children:[(0,G.jsx)(Nv,{label:`${i} devices`,size:`small`,sx:{fontSize:`0.65rem`,height:20}}),o>0&&(0,G.jsx)(Nv,{label:`${o} fabrics`,size:`small`,color:`primary`,variant:`outlined`,sx:{fontSize:`0.65rem`,height:20}}),a>0&&(0,G.jsx)(Nv,{label:`${a} failed`,size:`small`,color:`error`,sx:{fontSize:`0.65rem`,height:20}})]})]})},device:({data:e})=>{let{label:t,deviceType:n}=e;return(0,G.jsxs)(Z,{sx:{background:e=>e.palette.background.paper,border:`1px solid`,borderColor:`divider`,borderRadius:1.5,px:1.5,py:1,minWidth:150,maxWidth:200,boxShadow:`0 1px 6px rgba(0,0,0,0.06)`},children:[(0,G.jsx)(e7,{type:`target`,position:P6.Left,style:{opacity:0}}),(0,G.jsx)(e7,{type:`target`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(xb,{sx:{fontSize:14,color:`text.secondary`}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:600,noWrap:!0,sx:{maxWidth:160},children:t})]}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,sx:{fontSize:`0.6rem`,mt:.25},noWrap:!0,children:n})]})},fabric:({data:e})=>{let{label:t,vendorId:n}=e,r=wm(),i=Dx(n)===`Vendor ${n}`?t||`Vendor ${n}`:Dx(n);return(0,G.jsxs)(Z,{sx:{background:`linear-gradient(135deg, ${r.palette.secondary.dark}, ${r.palette.secondary.main})`,borderRadius:2,px:1.5,py:1,minWidth:140,color:r.palette.secondary.contrastText,boxShadow:`0 2px 12px ${r.palette.mode===`dark`?`rgba(0,0,0,0.4)`:`rgba(123,31,162,0.3)`}`},children:[(0,G.jsx)(e7,{type:`source`,position:P6.Right,style:{opacity:0}}),(0,G.jsx)(e7,{type:`source`,position:P6.Bottom,style:{opacity:0},id:`bottom`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Ihe,{sx:{fontSize:16}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:700,children:i})]}),t&&t!==i&&(0,G.jsx)(Q,{variant:`caption`,display:`block`,sx:{opacity:.8,fontSize:`0.6rem`},children:t})]})},failed:({data:e})=>{let{label:t,reason:n}=e,{mode:r}=Pm(),i=r===`dark`,a=i?`#ef5350`:`#d32f2f`;return(0,G.jsxs)(Z,{sx:{background:i?`#3a1515`:`#ffebee`,border:`1px dashed #f44336`,borderRadius:1.5,px:1.5,py:1,minWidth:150,maxWidth:200,opacity:.85},children:[(0,G.jsx)(e7,{type:`target`,position:P6.Left,style:{opacity:0}}),(0,G.jsx)(e7,{type:`target`,position:P6.Top,style:{opacity:0},id:`top`}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Cb,{sx:{fontSize:14,color:a}}),(0,G.jsx)(Q,{variant:`caption`,fontWeight:600,noWrap:!0,sx:{maxWidth:160,color:a},children:t})]}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,display:`block`,sx:{fontSize:`0.6rem`,mt:.25},noWrap:!0,title:n,children:n})]})}};function z7(e){return!e.parts||e.parts.length===0?e.endpoint===0?[]:[e]:e.parts.flatMap(z7)}function z0e(e,t,n,r){let i=[],a=[],o=e.reduce((e,t)=>e+t.deviceCount,0),s=new Map,c=e.map(e=>{let r=t[e.id],i=r?z7(r):[],a=e.failedEntities?.length??0,o=i.length+a,s=Math.min(o,n.devicesPerColumn);return{bridge:e,devices:i,height:Math.max(n.minBridgeSpacingY,s*n.deviceSpacingY+80)}}),l=c.reduce((e,t)=>e+t.height,0)/2;i.push({id:`hub`,type:`hub`,position:{x:n.hubX,y:l-60},data:{label:`HAMH`,bridgeCount:e.length,deviceCount:o}});let u=0;c.forEach(({bridge:e,devices:t,height:o})=>{let c=`bridge-${e.id}`,l=u+o/2,d=n.hubX+n.bridgeOffsetX,f=e.commissioning?.fabrics?.length??0,p=e.failedEntities?.length??0;if(i.push({id:c,type:`bridge`,position:{x:d,y:l-30},data:{label:e.name,status:e.status,port:e.port,deviceCount:e.deviceCount,failedCount:p,fabricCount:f}}),a.push({id:`hub-${c}`,source:`hub`,target:c,type:`smoothstep`,animated:e.status===`running`,style:{stroke:e.status===`running`?r.running:r.inactive,strokeWidth:2}}),e.commissioning?.fabrics)for(let t of e.commissioning.fabrics){let n=s.get(t.rootVendorId);n?n.bridgeIds.includes(e.id)||n.bridgeIds.push(e.id):s.set(t.rootVendorId,{vendorId:t.rootVendorId,label:t.label,bridgeIds:[e.id]})}let m=e.failedEntities??[],h=t.length+m.length,g=l-Math.min(h,n.devicesPerColumn)*n.deviceSpacingY/2,_=d+n.deviceOffsetX;t.forEach((t,o)=>{let s=Math.floor(o/n.devicesPerColumn),l=o%n.devicesPerColumn,u=`device-${e.id}-${t.id.global}`,d=Nx(t.state)??t.id.local;i.push({id:u,type:`device`,position:{x:_+s*n.deviceColumnSpacingX,y:g+l*n.deviceSpacingY},data:{label:d,deviceType:t.type.name,entityId:t.id.local}}),a.push({id:`${c}-${u}`,source:c,target:u,type:`smoothstep`,style:{stroke:r.device,strokeWidth:1}})}),m.forEach((o,s)=>{let l=t.length+s,u=Math.floor(l/n.devicesPerColumn),d=l%n.devicesPerColumn,f=`failed-${e.id}-${o.entityId}`;i.push({id:f,type:`failed`,position:{x:_+u*n.deviceColumnSpacingX,y:g+d*n.deviceSpacingY},data:{label:o.entityId,reason:o.reason}}),a.push({id:`${c}-${f}`,source:c,target:f,type:`smoothstep`,style:{stroke:r.failed,strokeWidth:1,strokeDasharray:`5,5`}})}),u+=o});let d=Array.from(s.values()),f=l-(d.length-1)*120/2;return d.forEach((e,t)=>{let o=`fabric-${e.vendorId}`;i.push({id:o,type:`fabric`,position:{x:n.hubX+n.fabricOffsetX,y:f+t*120},data:{label:e.label,vendorId:e.vendorId}});for(let t of e.bridgeIds)a.push({id:`${o}-bridge-${t}`,source:o,target:`bridge-${t}`,type:`smoothstep`,animated:!0,style:{stroke:r.fabric,strokeWidth:1.5}})}),{nodes:i,edges:a}}var B0e=()=>{let{t:e}=Ts(),t=tv(),{content:n,isLoading:r}=FT(),i=nv(e=>e.devices.byBridge),[a,o,s]=s0e([]),[c,l,u]=c0e([]),[d,f]=(0,C.useState)(!1),{mode:p}=Pm(),m=p===`dark`,h=(0,C.useRef)([]),[g,_]=(0,C.useState)(!1);(0,C.useEffect)(()=>{t(J_())},[t]),(0,C.useEffect)(()=>{if(n)for(let e of n)t(BT(e.id))},[t,n]);let v=(0,C.useMemo)(()=>{let e={};if(n)for(let t of n)e[t.id]=i[t.id]?.content;return e},[n,i]),y=(0,C.useMemo)(()=>!n||n.length===0?!0:n.every(e=>i[e.id]?.isInitialized),[n,i]);(0,C.useEffect)(()=>{if(!n||!y)return;let e=z0e(n,v,{hubX:400,minBridgeSpacingY:200,deviceSpacingY:55,devicesPerColumn:10,deviceColumnSpacingX:220,fabricOffsetX:-350,bridgeOffsetX:250,deviceOffsetX:280},{running:m?`#81c784`:`#4caf50`,inactive:m?`#616161`:`#bdbdbd`,device:m?`#90caf9`:`#64b5f6`,failed:m?`#ef5350`:`#f44336`,fabric:m?`#ce93d8`:`#ab47bc`});try{let t=localStorage.getItem(`hamh-network-map-positions`);if(t){let n=JSON.parse(t);for(let t of e.nodes)n[t.id]&&(t.position=n[t.id])}}catch{}o(e.nodes),l(e.edges)},[n,v,y,o,l,m]);let b=(0,C.useCallback)(()=>{t(J_())},[t]),x=(0,C.useCallback)((e,t)=>{let n=a.find(e=>e.id===t.id);n&&(h.current.push({nodeId:t.id,position:{...n.position}}),_(!0));let r=`hamh-network-map-positions`;try{let e=localStorage.getItem(r),n=e?JSON.parse(e):{};n[t.id]={x:t.position.x,y:t.position.y},localStorage.setItem(r,JSON.stringify(n))}catch{}},[a]),S=(0,C.useCallback)(()=>{localStorage.removeItem(`hamh-network-map-positions`),h.current=[],_(!1),t(J_())},[t]),w=(0,C.useCallback)(()=>{let e=h.current.pop();if(!e)return;_(h.current.length>0),o(t=>t.map(t=>t.id===e.nodeId?{...t,position:e.position}:t));let t=`hamh-network-map-positions`;try{let n=localStorage.getItem(t),r=n?JSON.parse(n):{};r[e.nodeId]=e.position,localStorage.setItem(t,JSON.stringify(r))}catch{}},[o]),T=r||!y;return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2},children:[(0,G.jsxs)(Q,{variant:`h4`,sx:{display:`flex`,alignItems:`center`,gap:2},children:[(0,G.jsx)(WT,{}),e(`networkMap.title`)]}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:.5},children:[(0,G.jsx)(vb,{title:e(`networkMap.undoMove`),children:(0,G.jsx)(`span`,{children:(0,G.jsx)(Vh,{onClick:w,color:`primary`,disabled:!g,children:(0,G.jsx)(gge,{})})})}),(0,G.jsx)(vb,{title:e(`networkMap.resetLayout`),children:(0,G.jsx)(Vh,{onClick:S,color:`primary`,children:(0,G.jsx)(pE,{})})}),(0,G.jsx)(vb,{title:e(`networkMap.refreshData`),children:(0,G.jsx)(Vh,{onClick:b,color:`primary`,children:(0,G.jsx)(fE,{})})}),(0,G.jsx)(vb,{title:e(d?`networkMap.exitFullscreen`:`networkMap.fullscreen`),children:(0,G.jsx)(Vh,{onClick:()=>f(e=>!e),color:`primary`,children:d?(0,G.jsx)(Xhe,{}):(0,G.jsx)(Yhe,{})})})]})]}),T?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:8},children:(0,G.jsx)(zh,{})}):(0,G.jsx)(Z,{sx:{width:`100%`,height:d?`calc(100vh - 100px)`:600,border:`1px solid`,borderColor:`divider`,borderRadius:2,overflow:`hidden`,transition:`height 0.3s ease`},children:(0,G.jsxs)(o0e,{nodes:a,edges:c,onNodesChange:s,onEdgesChange:u,onNodeDragStop:x,nodeTypes:R0e,colorMode:m?`dark`:`light`,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},children:[(0,G.jsx)(p0e,{variant:N7.Dots,gap:20,size:1}),(0,G.jsx)(b0e,{}),(0,G.jsx)(N0e,{nodeStrokeWidth:3,zoomable:!0,pannable:!0,nodeColor:e=>{switch(e.type){case`hub`:return`#1976d2`;case`bridge`:return`#4caf50`;case`fabric`:return`#9c27b0`;case`failed`:return`#f44336`;default:return m?`#90caf9`:`#90a4ae`}},style:{borderRadius:8}})]})}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:3,mt:2,flexWrap:`wrap`,alignItems:`center`},children:[(0,G.jsxs)(Q,{variant:`caption`,color:`text.secondary`,fontWeight:600,children:[e(`networkMap.legend`),`:`]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:`50%`,background:`linear-gradient(135deg, #7b1fa2, #9c27b0)`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.controller`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:`50%`,background:`linear-gradient(135deg, #1976d2, #1565c0)`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.hub`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:.5,background:m?`#1b3a1b`:`#e8f5e9`,border:`1px solid #4caf50`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.bridge`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:.5,background:m?`#2a2a2a`:`#fff`,border:`1px solid ${m?`#616161`:`#bdbdbd`}`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.device`)})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(Z,{sx:{width:12,height:12,borderRadius:.5,background:m?`#3a1515`:`#ffebee`,border:`1px dashed #f44336`}}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,children:e(`networkMap.failed`)})]})]})]})};function V0e(e){return Yd(`MuiTab`,e)}var B7=Xd(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`iconWrapper`,`icon`]),H0e=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e;return Tp({root:[`root`,a&&o&&`labelIcon`,`textColor${Y(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`iconWrapper`,`icon`]},V0e,t)},U0e=J(Ph,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${Y(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${B7.iconWrapper}`]:t.iconWrapper},{[`& .${B7.icon}`]:t.icon}]}})(Fm(({theme:e})=>({...e.typography.button,maxWidth:360,minWidth:90,position:`relative`,minHeight:48,flexShrink:0,padding:`12px 16px`,overflow:`hidden`,whiteSpace:`normal`,textAlign:`center`,lineHeight:1.25,variants:[{props:({ownerState:e})=>e.label&&(e.iconPosition===`top`||e.iconPosition===`bottom`),style:{flexDirection:`column`}},{props:({ownerState:e})=>e.label&&e.iconPosition!==`top`&&e.iconPosition!==`bottom`,style:{flexDirection:`row`}},{props:({ownerState:e})=>e.icon&&e.label,style:{minHeight:72,paddingTop:9,paddingBottom:9}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`top`,style:{[`& > .${B7.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${B7.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${B7.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${B7.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${B7.selected}`]:{opacity:1},[`&.${B7.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${B7.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${B7.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${B7.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${B7.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:({ownerState:e})=>e.fullWidth,style:{flexShrink:1,flexGrow:1,flexBasis:0,maxWidth:`none`}},{props:({ownerState:e})=>e.wrapped,style:{fontSize:e.typography.pxToRem(12)}}]}))),V7=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiTab`}),{className:r,disabled:i=!1,disableFocusRipple:a=!1,fullWidth:o,icon:s,iconPosition:c=`top`,indicator:l,label:u,onChange:d,onClick:f,onFocus:p,selected:m,selectionFollowsFocus:h,textColor:g=`inherit`,value:_,wrapped:v=!1,...y}=n,b={...n,disabled:i,disableFocusRipple:a,selected:m,icon:!!s,iconPosition:c,label:!!u,fullWidth:o,textColor:g,wrapped:v},x=H0e(b),S=s&&u&&C.isValidElement(s)?C.cloneElement(s,{className:K(x.icon,s.props.className)}):s;return(0,G.jsxs)(U0e,{focusRipple:!a,className:K(x.root,r),ref:t,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,_),f&&f(e)},onFocus:e=>{h&&!m&&d&&d(e,_),p&&p(e)},ownerState:b,tabIndex:m?0:-1,...y,children:[c===`top`||c===`start`?(0,G.jsxs)(C.Fragment,{children:[S,u]}):(0,G.jsxs)(C.Fragment,{children:[u,S]}),l]})});function W0e(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function G0e(e,t,n,r={},i=()=>{}){let{ease:a=W0e,duration:o=300}=r,s=null,c=t[e],l=!1,u=()=>{l=!0},d=r=>{if(l){i(Error(`Animation cancelled`));return}s===null&&(s=r);let u=Math.min(1,(r-s)/o);if(t[e]=a(u)*(n-c)+c,u>=1){requestAnimationFrame(()=>{i(null)});return}requestAnimationFrame(d)};return c===n?(i(Error(`Element already at target position`)),u):(requestAnimationFrame(d),u)}var K0e={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`};function q0e(e){let{onChange:t,...n}=e,r=C.useRef(),i=C.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return rh(()=>{let e=Xm(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=th(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),C.useEffect(()=>{a(),t(r.current)},[t]),(0,G.jsx)(`div`,{style:K0e,...n,ref:i})}var J0e=X((0,G.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Y0e=X((0,G.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function X0e(e){return Yd(`MuiTabScrollButton`,e)}var Z0e=Xd(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),Q0e=e=>{let{classes:t,orientation:n,disabled:r}=e;return Tp({root:[`root`,n,r&&`disabled`]},X0e,t)},$0e=J(Ph,{name:`MuiTabScrollButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.orientation&&t[n.orientation]]}})({width:40,flexShrink:0,opacity:.8,[`&.${Z0e.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),e2e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,u=Wf(),d={isRtl:u,...n},f=Q0e(d),p=i.StartScrollButtonIcon??J0e,m=i.EndScrollButtonIcon??Y0e,h=Xv({elementType:p,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:d}),g=Xv({elementType:m,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:d});return(0,G.jsx)($0e,{component:`div`,className:K(f.root,r),ref:t,role:null,ownerState:d,tabIndex:null,...l,style:{...l.style,...s===`vertical`&&{"--TabScrollButton-svgRotate":`rotate(${u?-90:90}deg)`}},children:o===`left`?(0,G.jsx)(p,{...h}):(0,G.jsx)(m,{...g})})});function t2e(e){return Yd(`MuiTabs`,e)}var H7=Xd(`MuiTabs`,[`root`,`vertical`,`list`,`flexContainer`,`flexContainerVertical`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),U7=(e,t)=>e===t?e.firstChild:t&&t.nextElementSibling?t.nextElementSibling:e.firstChild,W7=(e,t)=>e===t?e.lastChild:t&&t.previousElementSibling?t.previousElementSibling:e.lastChild,G7=(e,t,n)=>{let r=!1,i=n(e,t);for(;i;){if(i===e.firstChild){if(r)return;r=!0}let t=i.disabled||i.getAttribute(`aria-disabled`)===`true`;if(!i.hasAttribute(`tabindex`)||t)i=n(e,i);else{i.focus();return}}},n2e=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return Tp({root:[`root`,t&&`vertical`],scroller:[`scroller`,n&&`fixed`,r&&`hideScrollbar`,i&&`scrollableX`,a&&`scrollableY`],list:[`list`,`flexContainer`,t&&`flexContainerVertical`,t&&`vertical`,o&&`centered`],indicator:[`indicator`],scrollButtons:[`scrollButtons`,s&&`scrollButtonsHideMobile`],scrollableX:[i&&`scrollableX`],hideScrollbar:[r&&`hideScrollbar`]},t2e,c)},r2e=J(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${H7.scrollButtons}`]:t.scrollButtons},{[`& .${H7.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(Fm(({theme:e})=>({overflow:`hidden`,minHeight:48,WebkitOverflowScrolling:`touch`,display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.scrollButtonsHideMobile,style:{[`& .${H7.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),i2e=J(`div`,{name:`MuiTabs`,slot:`Scroller`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.scroller,n.fixed&&t.fixed,n.hideScrollbar&&t.hideScrollbar,n.scrollableX&&t.scrollableX,n.scrollableY&&t.scrollableY]}})({position:`relative`,display:`inline-block`,flex:`1 1 auto`,whiteSpace:`nowrap`,variants:[{props:({ownerState:e})=>e.fixed,style:{overflowX:`hidden`,width:`100%`}},{props:({ownerState:e})=>e.hideScrollbar,style:{scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}},{props:({ownerState:e})=>e.scrollableX,style:{overflowX:`auto`,overflowY:`hidden`}},{props:({ownerState:e})=>e.scrollableY,style:{overflowY:`auto`,overflowX:`hidden`}}]}),a2e=J(`div`,{name:`MuiTabs`,slot:`List`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.list,t.flexContainer,n.vertical&&t.flexContainerVertical,n.centered&&t.centered]}})({display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.centered,style:{justifyContent:`center`}}]}),o2e=J(`span`,{name:`MuiTabs`,slot:`Indicator`})(Fm(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,transition:e.transitions.create(),variants:[{props:{indicatorColor:`primary`},style:{backgroundColor:(e.vars||e).palette.primary.main}},{props:{indicatorColor:`secondary`},style:{backgroundColor:(e.vars||e).palette.secondary.main}},{props:({ownerState:e})=>e.vertical,style:{height:`100%`,width:2,right:0}}]}))),s2e=J(q0e)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),K7={},c2e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiTabs`}),r=wm(),i=Wf(),{"aria-label":a,"aria-labelledby":o,action:s,centered:c=!1,children:l,className:u,component:d=`div`,allowScrollButtonsMobile:f=!1,indicatorColor:p=`primary`,onChange:m,orientation:h=`horizontal`,ScrollButtonComponent:g,scrollButtons:_=`auto`,selectionFollowsFocus:v,slots:y={},slotProps:b={},TabIndicatorProps:x={},TabScrollButtonProps:S={},textColor:w=`primary`,value:T,variant:E=`standard`,visibleScrollbar:D=!1,...O}=n,k=E===`scrollable`,A=h===`vertical`,j=A?`scrollTop`:`scrollLeft`,M=A?`top`:`left`,N=A?`bottom`:`right`,P=A?`clientHeight`:`clientWidth`,F=A?`height`:`width`,I={...n,component:d,allowScrollButtonsMobile:f,indicatorColor:p,orientation:h,vertical:A,scrollButtons:_,textColor:w,variant:E,visibleScrollbar:D,fixed:!k,hideScrollbar:k&&!D,scrollableX:k&&!A,scrollableY:k&&A,centered:c&&!k,scrollButtonsHideMobile:!f},L=n2e(I),R=Xv({elementType:y.StartScrollButtonIcon,externalSlotProps:b.startScrollButtonIcon,ownerState:I}),ee=Xv({elementType:y.EndScrollButtonIcon,externalSlotProps:b.endScrollButtonIcon,ownerState:I}),[z,te]=C.useState(!1),[B,V]=C.useState(K7),[ne,re]=C.useState(!1),[ie,ae]=C.useState(!1),[oe,se]=C.useState(!1),[ce,le]=C.useState({overflow:`hidden`,scrollbarWidth:0}),ue=new Map,H=C.useRef(null),de=C.useRef(null),fe={slots:y,slotProps:{indicator:x,scrollButtons:S,...b}},U=()=>{let e=H.current,t;if(e){let n=e.getBoundingClientRect();t={clientWidth:e.clientWidth,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}let n;if(e&&T!==!1){let e=de.current.children;if(e.length>0){let t=e[ue.get(T)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},pe=ch(()=>{let{tabsMeta:e,tabMeta:t}=U(),n=0,r;A?(r=`top`,t&&e&&(n=t.top-e.top+e.scrollTop)):(r=i?`right`:`left`,t&&e&&(n=(i?-1:1)*(t[r]-e[r]+e.scrollLeft)));let a={[r]:n,[F]:t?t[F]:0};if(typeof B[r]!=`number`||typeof B[F]!=`number`)V(a);else{let e=Math.abs(B[r]-a[r]),t=Math.abs(B[F]-a[F]);(e>=1||t>=1)&&V(a)}}),me=(e,{animation:t=!0}={})=>{t?G0e(j,H.current,e,{duration:r.transitions.duration.standard}):H.current[j]=e},W=e=>{let t=H.current[j];A?t+=e:t+=e*(i?-1:1),me(t)},he=()=>{let e=H.current[P],t=0,n=Array.from(de.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[P]>e){r===0&&(t=e);break}t+=i[P]}return t},ge=()=>{W(-1*he())},_e=()=>{W(he())},[ve,{onChange:ye,...be}]=Um(`scrollbar`,{className:K(L.scrollableX,L.hideScrollbar),elementType:s2e,shouldForwardComponentProp:!0,externalForwardedProps:fe,ownerState:I}),xe=C.useCallback(e=>{ye?.(e),le({overflow:null,scrollbarWidth:e})},[ye]),[Se,Ce]=Um(`scrollButtons`,{className:K(L.scrollButtons,S.className),elementType:e2e,externalForwardedProps:fe,ownerState:I,additionalProps:{orientation:h,slots:{StartScrollButtonIcon:y.startScrollButtonIcon||y.StartScrollButtonIcon,EndScrollButtonIcon:y.endScrollButtonIcon||y.EndScrollButtonIcon},slotProps:{startScrollButtonIcon:R,endScrollButtonIcon:ee}}}),we=()=>{let e={};e.scrollbarSizeListener=k?(0,G.jsx)(ve,{...be,onChange:xe}):null;let t=k&&(_===`auto`&&(ne||ie)||_===!0);return e.scrollButtonStart=t?(0,G.jsx)(Se,{direction:i?`right`:`left`,onClick:ge,disabled:!ne,...Ce}):null,e.scrollButtonEnd=t?(0,G.jsx)(Se,{direction:i?`left`:`right`,onClick:_e,disabled:!ie,...Ce}):null,e},Te=ch(e=>{let{tabsMeta:t,tabMeta:n}=U();!n||!t||(n[M]<t[M]?me(t[j]+(n[M]-t[M]),{animation:e}):n[N]>t[N]&&me(t[j]+(n[N]-t[N]),{animation:e}))}),Ee=ch(()=>{k&&_!==!1&&se(!oe)});C.useEffect(()=>{let e=Xm(()=>{H.current&&pe()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),Ee()},r=th(H.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(de.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(de.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[pe,Ee]),C.useEffect(()=>{let e=Array.from(de.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&k&&_!==!1){let n=e[0],r=e[t-1],i={root:H.current,threshold:.99},a=new IntersectionObserver(e=>{re(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{ae(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[k,_,oe,l?.length]),C.useEffect(()=>{te(!0)},[]),C.useEffect(()=>{pe()}),C.useEffect(()=>{Te(K7!==B)},[Te,B]),C.useImperativeHandle(s,()=>({updateIndicator:pe,updateScrollButtons:Ee}),[pe,Ee]);let[De,Oe]=Um(`indicator`,{className:K(L.indicator,x.className),elementType:o2e,externalForwardedProps:fe,ownerState:I,additionalProps:{style:B}}),ke=(0,G.jsx)(De,{...Oe}),Ae=0,je=C.Children.map(l,e=>{if(!C.isValidElement(e))return null;let t=e.props.value===void 0?Ae:e.props.value;ue.set(t,Ae);let n=t===T;return Ae+=1,C.cloneElement(e,{fullWidth:E===`fullWidth`,indicator:n&&!z&&ke,selected:n,selectionFollowsFocus:v,onChange:m,textColor:w,value:t,...Ae===1&&T===!1&&!e.props.tabIndex?{tabIndex:0}:{}})}),Me=e=>{if(e.altKey||e.shiftKey||e.ctrlKey||e.metaKey)return;let t=de.current,n=Lb($m(t));if(n?.getAttribute(`role`)!==`tab`)return;let r=h===`horizontal`?`ArrowLeft`:`ArrowUp`,a=h===`horizontal`?`ArrowRight`:`ArrowDown`;switch(h===`horizontal`&&i&&(r=`ArrowRight`,a=`ArrowLeft`),e.key){case r:e.preventDefault(),G7(t,n,W7);break;case a:e.preventDefault(),G7(t,n,U7);break;case`Home`:e.preventDefault(),G7(t,null,U7);break;case`End`:e.preventDefault(),G7(t,null,W7);break;default:break}},Ne=we(),[Pe,Fe]=Um(`root`,{ref:t,className:K(L.root,u),elementType:r2e,externalForwardedProps:{...fe,...O,component:d},ownerState:I}),[Ie,Le]=Um(`scroller`,{ref:H,className:L.scroller,elementType:i2e,externalForwardedProps:fe,ownerState:I,additionalProps:{style:{overflow:ce.overflow,[A?`margin${i?`Left`:`Right`}`:`marginBottom`]:D?void 0:-ce.scrollbarWidth}}}),[Re,ze]=Um(`list`,{ref:de,className:K(L.list,L.flexContainer),elementType:a2e,externalForwardedProps:fe,ownerState:I,getSlotProps:e=>({...e,onKeyDown:t=>{Me(t),e.onKeyDown?.(t)}})});return(0,G.jsxs)(Pe,{...Fe,children:[Ne.scrollButtonStart,Ne.scrollbarSizeListener,(0,G.jsxs)(Ie,{...Le,children:[(0,G.jsx)(Re,{"aria-label":a,"aria-labelledby":o,"aria-orientation":h===`vertical`?`vertical`:null,role:`tablist`,...ze,children:je}),z&&ke]}),Ne.scrollButtonEnd]})});async function q7(e,t){let n=await fetch(e,t);if(!n.ok)throw Error(`${n.status} ${n.statusText}`);return n.json()}var l2e=()=>{let[e,t]=(0,C.useState)([]),[n,r]=(0,C.useState)([]),[i,a]=(0,C.useState)(!0),[o,s]=(0,C.useState)(),[c,l]=(0,C.useState)(!1),[u,d]=(0,C.useState)(0),[f,p]=(0,C.useState)(``),[m,h]=(0,C.useState)(``),[g,_]=(0,C.useState)(null),[v,y]=(0,C.useState)(!1),b=(0,C.useRef)(null),x=(0,C.useCallback)(async()=>{a(!0),s(void 0);try{let[e,n]=await Promise.all([q7(`api/plugins`),q7(`api/plugins/installed`)]);t(e),r(n)}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}},[]);(0,C.useEffect)(()=>{x()},[x]);let S=async()=>{if(f.trim()){y(!0);try{await q7(`api/plugins/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({packageName:f.trim()})}),p(``),l(!1),await x()}catch(e){s(e instanceof Error?e.message:String(e))}finally{y(!1)}}},w=async()=>{if(g){y(!0);try{let e=await g.arrayBuffer(),t=await fetch(`api/plugins/upload`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:e});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`${t.status} ${t.statusText}`)}_(null),b.current&&(b.current.value=``),l(!1),await x()}catch(e){s(e instanceof Error?e.message:String(e))}finally{y(!1)}}},T=async()=>{if(m.trim()){y(!0);try{await q7(`api/plugins/install-local`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:m.trim()})}),h(``),l(!1),await x()}catch(e){s(e instanceof Error?e.message:String(e))}finally{y(!1)}}},E=async e=>{try{await q7(`api/plugins/uninstall`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({packageName:e})}),await x()}catch(e){s(e instanceof Error?e.message:String(e))}},D=async(e,t,n)=>{try{await q7(`api/plugins/${e}/${t}/${n}`,{method:`POST`}),await x()}catch(e){s(e instanceof Error?e.message:String(e))}};if(i)return(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,py:6},children:(0,G.jsx)(zh,{})});let O=e.reduce((e,t)=>e+t.plugins.length,0);return(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:3,p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,G.jsxs)(Q,{variant:`h5`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(nE,{}),` Plugins`]}),(0,G.jsxs)(Yv,{direction:`row`,spacing:1,children:[(0,G.jsx)(vb,{title:`Refresh`,children:(0,G.jsx)(Vh,{onClick:x,children:(0,G.jsx)(fE,{})})}),(0,G.jsx)(xv,{variant:`contained`,startIcon:(0,G.jsx)(yb,{}),onClick:()=>l(!0),size:`small`,children:`Install Plugin`})]})]}),o&&(0,G.jsx)(Wh,{severity:`error`,onClose:()=>s(void 0),children:o}),O===0&&n.length===0&&(0,G.jsx)(Wh,{severity:`info`,children:`No plugins installed. Click "Install Plugin" to add an npm plugin package, or plugins will appear here when registered by the bridge.`}),n.length>0&&(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`h6`,gutterBottom:!0,children:`Installed Packages`}),(0,G.jsx)(oy,{dense:!0,children:n.map(e=>(0,G.jsxs)(ly,{secondaryAction:(0,G.jsx)(vb,{title:`Uninstall`,children:(0,G.jsx)(Vh,{edge:`end`,onClick:()=>E(e.packageName),color:`error`,size:`small`,children:(0,G.jsx)(RS,{})})}),children:[(0,G.jsx)(dy,{children:(0,G.jsx)(nE,{})}),(0,G.jsx)(py,{primary:e.packageName,secondary:`v${e.version}, installed ${new Date(e.installedAt).toLocaleDateString()}`})]},e.packageName))})]})}),e.map(e=>(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`h6`,gutterBottom:!0,children:e.bridgeName}),e.plugins.length===0?(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,children:`No active plugins on this bridge.`}):(0,G.jsx)(oy,{dense:!0,children:e.plugins.map(t=>(0,G.jsxs)(Z,{children:[(0,G.jsxs)(ly,{secondaryAction:(0,G.jsxs)(Yv,{direction:`row`,spacing:.5,children:[t.circuitBreaker?.disabled&&(0,G.jsx)(vb,{title:`Reset circuit breaker`,children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>D(e.bridgeId,t.name,`reset`),children:(0,G.jsx)(pE,{})})}),(0,G.jsx)(vb,{title:t.enabled?`Disable`:`Enable`,children:(0,G.jsx)(Vh,{size:`small`,onClick:()=>D(e.bridgeId,t.name,t.enabled?`disable`:`enable`),children:t.enabled?(0,G.jsx)(oge,{}):(0,G.jsx)(age,{})})})]}),children:[(0,G.jsx)(dy,{children:(0,G.jsx)(nE,{color:t.enabled?`primary`:`disabled`})}),(0,G.jsx)(py,{primary:(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[t.name,(0,G.jsx)(Nv,{label:`v${t.version}`,size:`small`,variant:`outlined`}),t.source===`builtin`&&(0,G.jsx)(Nv,{label:`built-in`,size:`small`}),!t.enabled&&(0,G.jsx)(Nv,{label:`disabled`,size:`small`,color:`warning`}),t.circuitBreaker?.disabled&&(0,G.jsx)(Nv,{label:`circuit breaker open`,size:`small`,color:`error`})]}),secondary:t.devices.length>0?`${t.devices.length} device(s)`:`No devices registered`})]}),t.circuitBreaker?.disabled&&t.circuitBreaker.lastError&&(0,G.jsx)(Wh,{severity:`error`,sx:{mx:2,mb:1},children:t.circuitBreaker.lastError}),t.devices.length>0&&(0,G.jsx)(oy,{dense:!0,sx:{pl:6},children:t.devices.map(e=>(0,G.jsx)(ly,{children:(0,G.jsx)(py,{primary:e.name,secondary:`${e.deviceType}, ${e.id}`})},e.id))}),(0,G.jsx)(Xb,{})]},t.name))})]})},e.bridgeId)),(0,G.jsxs)(Gb,{open:c,onClose:()=>l(!1),maxWidth:`sm`,fullWidth:!0,children:[(0,G.jsx)(Jb,{children:`Install Plugin`}),(0,G.jsxs)(qb,{children:[(0,G.jsxs)(c2e,{value:u,onChange:(e,t)=>d(t),sx:{mb:2},children:[(0,G.jsx)(V7,{label:`npm`}),(0,G.jsx)(V7,{label:`Upload .tgz`}),(0,G.jsx)(V7,{label:`Local Path`})]}),u===0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(OS,{autoFocus:!0,margin:`dense`,label:`npm package name`,placeholder:`e.g. hamh-plugin-example`,fullWidth:!0,value:f,onChange:e=>p(e.target.value),disabled:v,onKeyDown:e=>{e.key===`Enter`&&S()}}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:`The plugin will be installed via npm. After installation, restart the bridge to load the plugin.`})]}),u===1&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(xv,{variant:`outlined`,component:`label`,startIcon:(0,G.jsx)(CE,{}),fullWidth:!0,sx:{mt:1},disabled:v,children:[g?g.name:`Choose .tgz file`,(0,G.jsx)(`input`,{ref:b,type:`file`,accept:`.tgz,application/gzip`,hidden:!0,onChange:e=>_(e.target.files?.[0]??null)})]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:`Upload a packaged plugin (.tgz). Restart the bridge after installation.`})]}),u===2&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(OS,{autoFocus:!0,margin:`dense`,label:`Absolute path to plugin folder`,placeholder:`/path/to/your/plugin`,fullWidth:!0,value:m,onChange:e=>h(e.target.value),disabled:v,InputProps:{startAdornment:(0,G.jsx)(Jhe,{sx:{mr:1}})},onKeyDown:e=>{e.key===`Enter`&&T()}}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:`Link a local plugin directory (creates a symlink). Useful for development. Restart the bridge after linking.`})]})]}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>l(!1),disabled:v,children:`Cancel`}),u===0&&(0,G.jsx)(xv,{onClick:S,variant:`contained`,disabled:v||!f.trim(),children:v?(0,G.jsx)(zh,{size:20}):`Install`}),u===1&&(0,G.jsx)(xv,{onClick:w,variant:`contained`,disabled:v||!g,children:v?(0,G.jsx)(zh,{size:20}):`Upload`}),u===2&&(0,G.jsx)(xv,{onClick:T,variant:`contained`,disabled:v||!m.trim(),children:v?(0,G.jsx)(zh,{size:20}):`Link`})]})]})]})};async function u2e(){let e=await fetch(`api/settings/auth`);return await z_(e,`Failed to fetch auth settings`),R_(e)}async function d2e(e,t){let n=await fetch(`api/settings/auth`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})});return await z_(n,`Failed to update auth settings`),R_(n)}async function f2e(){let e=await fetch(`api/settings/auth`,{method:`DELETE`});return await z_(e,`Failed to delete auth settings`),R_(e)}async function p2e(){let e=await fetch(`api/settings/recovery`);return await z_(e,`Failed to fetch recovery settings`),R_(e)}async function m2e(e){let t=await fetch(`api/settings/recovery`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return await z_(t,`Failed to update recovery settings`),R_(t)}var h2e=()=>{let{t:e}=Ts(),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(null),s=(0,C.useCallback)(async()=>{i(!0),o(null);try{let t=await fetch(`api/system/update-check`);t.ok?n(await t.json()):t.status===404?o(e(`updateChecker.notAvailable`)):o(e(`updateChecker.checkFailed`))}catch{o(e(`updateChecker.unreachable`))}finally{i(!1)}},[e]);return(0,C.useEffect)(()=>{s()},[s]),(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,mb:2},children:[(0,G.jsxs)(Q,{variant:`h6`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(ige,{}),e(`updateChecker.title`)]}),(0,G.jsx)(xv,{size:`small`,startIcon:r?(0,G.jsx)(zh,{size:16}):(0,G.jsx)(fE,{}),onClick:s,disabled:r,children:e(`updateChecker.checkNow`)})]}),a&&(0,G.jsx)(Wh,{severity:`warning`,sx:{mb:2},children:a}),t&&(0,G.jsxs)(Yv,{spacing:2,children:[(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[e(`updateChecker.currentVersion`),`:`]}),(0,G.jsx)(Nv,{label:t.currentVersion,size:`small`,color:`primary`})]}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`},children:[(0,G.jsxs)(Q,{variant:`body2`,children:[e(`updateChecker.latestVersion`),`:`]}),(0,G.jsx)(Nv,{label:t.latestVersion,size:`small`,color:t.updateAvailable?`warning`:`success`})]}),t.updateAvailable?(0,G.jsxs)(Wh,{severity:`info`,action:(0,G.jsx)(xv,{color:`inherit`,size:`small`,endIcon:(0,G.jsx)(lE,{}),href:t.releaseUrl,target:`_blank`,rel:`noopener noreferrer`,children:e(`updateChecker.releaseNotes`)}),children:[(0,G.jsx)(Q,{variant:`body2`,sx:{fontWeight:600},children:e(`updateChecker.updateAvailable`)}),(0,G.jsx)(Q,{variant:`body2`,children:(t=>{switch(t){case`Home Assistant Add-on`:return e(`updateChecker.instructionAddon`);case`Docker`:return e(`updateChecker.instructionDocker`);default:return e(`updateChecker.instructionNpm`)}})(t.environment)})]}):(0,G.jsx)(Wh,{severity:`success`,children:e(`updateChecker.upToDate`)}),t.releaseNotes&&t.updateAvailable&&(0,G.jsx)(Z,{sx:{p:1.5,borderRadius:1,bgcolor:`action.hover`,maxHeight:400,overflow:`auto`},children:(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{whiteSpace:`pre-wrap`},children:t.releaseNotes})})]})]})})},J7=10,Y7=3600,g2e=()=>{let{t:e}=Ts(),[t,n]=(0,C.useState)(!1),[r,i]=(0,C.useState)(60),[a,o]=(0,C.useState)(!0),[s,c]=(0,C.useState)(!1),[l,u]=(0,C.useState)(null);return(0,C.useEffect)(()=>{p2e().then(e=>{n(e.autoRecoveryEnabled),i(Math.round(e.recoveryIntervalMs/1e3))}).catch(e=>u(e instanceof Error?e.message:String(e))).finally(()=>o(!1))},[]),(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsx)(Q,{variant:`h6`,sx:{mb:2},children:e(`settings.recovery.title`,`Auto recovery`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`settings.recovery.hint`,`Periodically restarts bridges that failed to start. Only failed bridges are touched.`)}),l&&(0,G.jsx)(Wh,{severity:`error`,sx:{mb:2},children:l}),a?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:2},children:(0,G.jsx)(zh,{})}):(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2},children:[(0,G.jsx)(Vv,{control:(0,G.jsx)(qS,{checked:t,onChange:e=>n(e.target.checked)}),label:e(`settings.recovery.enabled`,`Enabled`)}),(0,G.jsx)(OS,{type:`number`,size:`small`,label:e(`settings.recovery.interval`,`Interval (seconds)`),value:r,disabled:!t,onChange:e=>i(Number(e.target.value)),slotProps:{htmlInput:{min:J7,max:Y7}},sx:{maxWidth:220}}),(0,G.jsx)(Z,{children:(0,G.jsx)(xv,{variant:`contained`,onClick:async()=>{c(!0),u(null);try{let e=await m2e({autoRecoveryEnabled:t,recoveryIntervalMs:r*1e3});n(e.autoRecoveryEnabled),i(Math.round(e.recoveryIntervalMs/1e3))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}},disabled:s||Number.isNaN(r)||r<J7||r>Y7,children:e(`common.save`,`Save`)})})]})]})})},_2e=()=>{let{t:e}=Ts(),[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(!0),[a,o]=(0,C.useState)(!1),[s,c]=(0,C.useState)(null),[l,u]=(0,C.useState)(null),[d,f]=(0,C.useState)(``),[p,m]=(0,C.useState)(``),h=(0,C.useCallback)(async()=>{i(!0);try{let e=await u2e();n(e),e.username&&f(e.username),c(null)}catch(t){c(t instanceof Error?t.message:e(`settings.authLoadFailed`))}finally{i(!1)}},[e]);(0,C.useEffect)(()=>{h()},[h]);let g=async()=>{if(!d.trim()||!p.trim()){c(e(`settings.usernamePasswordRequired`));return}o(!0),c(null),u(null);try{n(await d2e(d.trim(),p)),m(``),u(`Authentication enabled. The browser will prompt you to log in on the next request.`)}catch(t){c(t instanceof Error?t.message:e(`settings.authSaveFailed`))}finally{o(!1)}},[_,v]=(0,C.useState)(!1),y=async()=>{v(!1),o(!0),c(null),u(null);try{n(await f2e()),f(``),m(``),u(e(`settings.authDisabled`))}catch(t){c(t instanceof Error?t.message:e(`settings.authRemoveFailed`))}finally{o(!1)}},b=t?.source===`environment`;return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Q,{variant:`h5`,component:`h1`,sx:{mb:3},children:[(0,G.jsx)(MT,{sx:{mr:1,verticalAlign:`middle`}}),e(`settings.title`)]}),(0,G.jsx)(r4,{}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsx)(h2e,{}),(0,G.jsx)(Xb,{sx:{my:3}}),(0,G.jsx)(g2e,{}),(0,G.jsx)(Xb,{sx:{my:3}}),r?(0,G.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,p:4},children:(0,G.jsx)(zh,{})}):(0,G.jsx)(Sv,{children:(0,G.jsxs)(Tv,{children:[(0,G.jsxs)(Q,{variant:`h6`,sx:{mb:2},children:[(0,G.jsx)(_E,{sx:{mr:1,verticalAlign:`middle`,fontSize:20}}),e(`settings.title`)]}),b&&(0,G.jsxs)(Wh,{severity:`info`,sx:{mb:2},children:[`Authentication is configured via environment variables (`,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_USERNAME`}),` /`,` `,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_PASSWORD`}),`). Remove the environment variables to manage authentication from here.`]}),s&&(0,G.jsx)(Wh,{severity:`error`,sx:{mb:2},children:s}),l&&(0,G.jsx)(Wh,{severity:`success`,sx:{mb:2},children:l}),t?.enabled&&!b&&(0,G.jsxs)(Wh,{severity:`info`,sx:{mb:2},children:[`Authentication is currently enabled for user "`,t.username,`". Enter a new password to change it, or remove authentication entirely.`]}),(0,G.jsxs)(Z,{sx:{display:`flex`,flexDirection:`column`,gap:2,maxWidth:400},children:[(0,G.jsx)(OS,{label:e(`settings.username`),value:d,onChange:e=>f(e.target.value),disabled:b||a,fullWidth:!0,size:`small`}),(0,G.jsx)(OS,{label:e(`settings.password`),type:`password`,value:p,onChange:e=>m(e.target.value),disabled:b||a,fullWidth:!0,size:`small`,placeholder:t?.enabled&&!b?e(`settings.enterNewPassword`):``}),(0,G.jsxs)(Z,{sx:{display:`flex`,gap:1},children:[(0,G.jsx)(xv,{variant:`contained`,onClick:g,disabled:b||a||!d.trim()||!p.trim(),startIcon:a?(0,G.jsx)(zh,{size:16}):(0,G.jsx)(hE,{}),children:t?.enabled&&!b?e(`common.update`):e(`settings.enableAuth`)}),t?.enabled&&!b&&(0,G.jsx)(xv,{variant:`outlined`,color:`error`,onClick:()=>v(!0),disabled:a,startIcon:(0,G.jsx)(RS,{}),children:e(`common.disabled`)})]})]}),(0,G.jsxs)(Wh,{severity:`warning`,sx:{mt:3},children:[`If you get locked out, delete the settings from the storage directory or set `,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_USERNAME`}),` /`,` `,(0,G.jsx)(`code`,{children:`HAMH_HTTP_AUTH_PASSWORD`}),` environment variables in your Docker Compose file to regain access.`]})]})}),(0,G.jsx)(VT,{open:_,title:e(`settings.disableAuth`),message:e(`settings.disableAuthMessage`),confirmLabel:e(`settings.disableAuthConfirm`),confirmColor:`error`,onConfirm:y,onCancel:()=>v(!1)})]})};function v2e(e){let t=e.filter?.include??[];if(t.length!==0)return t.map(e=>e.type===ov.Pattern?e.value:`${e.type}: ${e.value}`).join(`, `)}var X7=/^[a-z0-9_]+\.[a-z0-9_]+$/,y2e=10;function Z7(e){return e?.message}var b2e=()=>{let{t:e}=Ts(),t=ey(),n=tv(),{content:r,isLoading:i}=FT(),a=RT(),o=zT(),[s,c]=(0,C.useState)(!1),[l,u]=(0,C.useState)(``),d=(0,C.useRef)(0),[f,p]=(0,C.useState)([{key:0,value:``}]),[m,h]=(0,C.useState)(!1),[g,_]=(0,C.useState)(null),v=f.map(e=>e.value.trim()),y=v.filter(e=>e!==``),b=e=>{let t=v[e];return t===``?!1:X7.test(t)?v.indexOf(t)!==e:!0},x=y.length>0&&f.every((e,t)=>!b(t)),S=(r??[]).filter(e=>e.featureFlags?.serverMode===!0),w=(0,C.useCallback)(async()=>{let r=l.trim(),i=f.map(e=>e.value.trim()).filter(e=>e!==``);if(!(!r||i.length===0||i.some(e=>!X7.test(e))||new Set(i).size!==i.length)){h(!0);try{await a({name:r,filter:{include:i.map(e=>({type:ov.Pattern,value:e})),exclude:[]},featureFlags:{serverMode:!0}}),t.show({message:e(`standaloneDevices.created`,`Standalone device created`),severity:`success`}),c(!1),u(``),p([{key:0,value:``}]),n(J_())}catch(n){t.show({message:Z7(n)??e(`standaloneDevices.createFailed`,`Could not create device`),severity:`error`})}finally{h(!1)}}},[l,f,a,t,e,n]),T=(0,C.useCallback)(async r=>{try{await o(r.id),t.show({message:e(`standaloneDevices.deleted`,`Standalone device deleted`),severity:`success`}),n(J_())}catch(n){t.show({message:Z7(n)??e(`standaloneDevices.deleteFailed`,`Could not delete device`),severity:`error`})}},[o,t,e,n]);return(0,G.jsxs)(Z,{sx:{p:2},children:[(0,G.jsxs)(Z,{sx:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,mb:1},children:[(0,G.jsx)(Q,{variant:`h5`,component:`h1`,children:e(`standaloneDevices.title`,`Standalone Devices`)}),(0,G.jsx)(xv,{variant:`contained`,startIcon:(0,G.jsx)(yb,{}),onClick:()=>c(!0),children:e(`standaloneDevices.create`,`Add device`)})]}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,sx:{mb:2},children:e(`standaloneDevices.subtitle`,`Each device runs on its own Matter node with its own pairing code, instead of inside a bridge.`)}),i&&!r?(0,G.jsx)(zh,{}):S.length===0?(0,G.jsx)(Wh,{severity:`info`,children:e(`standaloneDevices.empty`,`No standalone devices yet. Add one to expose a single entity as its own Matter device.`)}):(0,G.jsx)(Yv,{spacing:1,children:S.map(t=>(0,G.jsx)(Sv,{variant:`outlined`,children:(0,G.jsxs)(Tv,{sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:2},children:[(0,G.jsxs)(Z,{sx:{minWidth:0},children:[(0,G.jsx)(Q,{variant:`subtitle1`,noWrap:!0,children:t.name}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:v2e(t)??e(`standaloneDevices.noEntity`,`no entity`)})]}),(0,G.jsxs)(Yv,{direction:`row`,spacing:1,alignItems:`center`,children:[(t.failedEntities?.length??0)>0&&(0,G.jsx)(vb,{title:t.failedEntities?.map(e=>e.reason).join(` `)??``,children:(0,G.jsx)(Nv,{size:`small`,color:`warning`,label:e(`standaloneDevices.entityProblem`,`entity problem`)})}),(0,G.jsx)(kx,{status:t.status,reason:t.statusReason}),(0,G.jsx)(vb,{title:e(`standaloneDevices.openBridge`,`Open details and pairing`),children:(0,G.jsx)(Vh,{component:da,to:Y9.bridge(t.id),size:`small`,children:(0,G.jsx)($he,{fontSize:`small`})})}),(0,G.jsx)(vb,{title:e(`common.delete`,`Delete`),children:(0,G.jsx)(Vh,{onClick:()=>_(t),size:`small`,color:`error`,children:(0,G.jsx)(eE,{fontSize:`small`})})})]})]})},t.id))}),(0,G.jsxs)(Gb,{open:s,onClose:()=>{m||c(!1)},fullWidth:!0,maxWidth:`sm`,children:[(0,G.jsx)(Jb,{children:e(`standaloneDevices.create`,`Add device`)}),(0,G.jsxs)(qb,{children:[(0,G.jsx)(OS,{label:e(`standaloneDevices.name`,`Name`),value:l,onChange:e=>u(e.target.value),fullWidth:!0,margin:`normal`,slotProps:{htmlInput:{maxLength:32}}}),f.map((t,n)=>(0,G.jsxs)(Z,{sx:{display:`flex`,gap:1,alignItems:`flex-start`},children:[(0,G.jsx)(Z,{sx:{flexGrow:1},children:(0,G.jsx)(ZS,{value:t.value,onChange:e=>{p(n=>n.map(n=>n.key===t.key?{...n,value:e}:n))},label:n===0?e(`standaloneDevices.entity`,`Entity`):e(`standaloneDevices.additionalEntity`,`Additional entity`),helperText:b(n)?e(`standaloneDevices.entityInvalid`,`Enter a single entity id like vacuum.living_room, wildcards are not allowed.`):n===0?e(`standaloneDevices.entityHelp`,`Pick the Home Assistant entity to expose.`):void 0})}),f.length>1&&(0,G.jsx)(Vh,{size:`small`,sx:{mt:3},onClick:()=>p(e=>e.filter(e=>e.key!==t.key)),children:(0,G.jsx)(eE,{fontSize:`small`})})]},t.key)),(0,G.jsx)(xv,{size:`small`,startIcon:(0,G.jsx)(yb,{}),disabled:f.length>=y2e,onClick:()=>{d.current+=1,p(e=>[...e,{key:d.current,value:``}])},children:e(`standaloneDevices.addEntity`,`Add another entity`)}),(0,G.jsx)(Q,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:1},children:e(`standaloneDevices.multiHint`,`The first entity is the primary and names the device. More than one entity per device is experimental.`)})]}),(0,G.jsxs)(Kb,{children:[(0,G.jsx)(xv,{onClick:()=>c(!1),disabled:m,children:e(`common.cancel`,`Cancel`)}),(0,G.jsx)(xv,{onClick:w,variant:`contained`,disabled:m||!l.trim()||!x,children:m?e(`standaloneDevices.creating`,`Creating`):e(`common.create`,`Create`)})]})]}),(0,G.jsx)(VT,{open:g!==null,title:e(`standaloneDevices.confirmDeleteTitle`,`Delete standalone device`),message:e(`standaloneDevices.confirmDeleteMessage`,`This deletes the device's Matter node and unpairs it from your controllers. This cannot be undone.`),confirmLabel:e(`common.delete`,`Delete`),cancelLabel:e(`common.cancel`,`Cancel`),confirmColor:`error`,onConfirm:()=>{let e=g;_(null),e&&T(e)},onCancel:()=>_(null)})]})};function x2e(){var e=[...arguments];return(0,C.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var Q7=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function $7(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function e9(e){return`nodeType`in e}function t9(e){return e?$7(e)?e:e9(e)?e.ownerDocument?.defaultView??window:window:window}function n9(e){let{Document:t}=t9(e);return e instanceof t}function r9(e){return $7(e)?!1:e instanceof t9(e).HTMLElement}function i9(e){return e instanceof t9(e).SVGElement}function a9(e){return e?$7(e)?e.document:e9(e)?n9(e)?e:r9(e)||i9(e)?e.ownerDocument:document:document:document}var o9=Q7?C.useLayoutEffect:C.useEffect;function s9(e){let t=(0,C.useRef)(e);return o9(()=>{t.current=e}),(0,C.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function S2e(){let e=(0,C.useRef)(null);return[(0,C.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,C.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function c9(e,t){t===void 0&&(t=[e]);let n=(0,C.useRef)(e);return o9(()=>{n.current!==e&&(n.current=e)},t),n}function l9(e,t){let n=(0,C.useRef)();return(0,C.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function u9(e){let t=s9(e),n=(0,C.useRef)(null);return[n,(0,C.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function d9(e){let t=(0,C.useRef)();return(0,C.useEffect)(()=>{t.current=e},[e]),t.current}var f9={};function p9(e,t){return(0,C.useMemo)(()=>{if(t)return t;let n=f9[e]==null?0:f9[e]+1;return f9[e]=n,e+`-`+n},[e,t])}function C2e(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var m9=C2e(1),h9=C2e(-1);function w2e(e){return`clientX`in e&&`clientY`in e}function g9(e){if(!e)return!1;let{KeyboardEvent:t}=t9(e.target);return t&&e instanceof t}function T2e(e){if(!e)return!1;let{TouchEvent:t}=t9(e.target);return t&&e instanceof t}function _9(e){if(T2e(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return w2e(e)?{x:e.clientX,y:e.clientY}:null}var v9=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[v9.Translate.toString(e),v9.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),E2e=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function D2e(e){return e.matches(E2e)?e:e.querySelector(E2e)}var O2e={display:`none`};function k2e(e){let{id:t,value:n}=e;return C.createElement(`div`,{id:t,style:O2e},n)}function A2e(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return C.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function j2e(){let[e,t]=(0,C.useState)(``);return{announce:(0,C.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var M2e=(0,C.createContext)(null);function N2e(e){let t=(0,C.useContext)(M2e);(0,C.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function P2e(){let[e]=(0,C.useState)(()=>new Set),t=(0,C.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,C.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var F2e={draggable:`
466
466
  To pick up a draggable item, press the space bar.
467
467
  While dragging, use the arrow keys to move the item.
468
468
  Press space again to drop the item in its new position, or press escape to cancel.
469
- `},I2e={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 L2e(e){let{announcements:t=I2e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=F2e}=e,{announce:a,announcement:o}=j2e(),s=p9(`DndLiveRegion`),[c,l]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{l(!0)},[]),N2e((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(k2e,{id:r,value:i.draggable}),C.createElement(A2e,{id:s,announcement:o}));return n?(0,Aa.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 R2e(e,t){return(0,C.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function z2e(){var e=[...arguments];return(0,C.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var x9=Object.freeze({x:0,y:0});function B2e(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function V2e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function H2e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function U2e(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 W2e(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function G2e(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 K2e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=G2e(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=B2e(G2e(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(V2e)},q2e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=U2e(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=U2e(r),o=i.reduce((e,t,r)=>e+B2e(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(V2e)};function J2e(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 Y2e=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=J2e(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(H2e)};function X2e(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Z2e(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:x9}function Q2e(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 $2e=Q2e(1);function e4e(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 t4e(e,t,n){let r=e4e(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 n4e={ignoreTransform:!1};function S9(e,t){t===void 0&&(t=n4e);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=t9(e).getComputedStyle(e);t&&(n=t4e(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 r4e(e){return S9(e,{ignoreTransform:!0})}function i4e(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function a4e(e,t){return t===void 0&&(t=t9(e).getComputedStyle(e)),t.position===`fixed`}function o4e(e,t){t===void 0&&(t=t9(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(n9(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!r9(i)||i9(i)||n.includes(i))return n;let a=t9(e).getComputedStyle(i);return i!==e&&o4e(i,a)&&n.push(i),a4e(i,a)?n:r(i.parentNode)}return e?r(e):n}function s4e(e){let[t]=C9(e,1);return t??null}function w9(e){return!Q7||!e?null:$7(e)?e:e9(e)?n9(e)||e===a9(e).scrollingElement?window:r9(e)?e:null:null}function c4e(e){return $7(e)?e.scrollX:e.scrollLeft}function l4e(e){return $7(e)?e.scrollY:e.scrollTop}function T9(e){return{x:c4e(e),y:l4e(e)}}var E9;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(E9||={});function u4e(e){return!Q7||!e?!1:e===document.scrollingElement}function d4e(e){let t={x:0,y:0},n=u4e(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 f4e={x:.2,y:.2};function p4e(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=f4e);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=d4e(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 m4e(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 h4e(e){return e.reduce((e,t)=>m9(e,T9(t)),x9)}function g4e(e){return e.reduce((e,t)=>e+c4e(t),0)}function _4e(e){return e.reduce((e,t)=>e+l4e(t),0)}function v4e(e,t){if(t===void 0&&(t=S9),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);s4e(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var y4e=[[`x`,[`left`,`right`],g4e],[`y`,[`top`,`bottom`],_4e]],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=h4e(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of y4e)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 b4e(e){let{EventTarget:t}=t9(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 x4e(e){e.preventDefault()}function S4e(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 C4e={start:[j9.Space,j9.Enter],cancel:[j9.Esc],end:[j9.Space,j9.Enter,j9.Tab]},w4e=(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(t9(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&&v4e(n),t(x9)}handleKeyDown(e){if(g9(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=C4e,coordinateGetter:a=w4e,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}=d4e(n),p=m4e(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=C4e,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 T4e(e){return!!(e&&`distance`in e)}function E4e(e){return!!(e&&`delay`in e)}var N9=class{constructor(e,t,n){n===void 0&&(n=b4e(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(t9(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,x4e),this.windowListeners.add(A9.VisibilityChange,this.handleCancel),this.windowListeners.add(A9.ContextMenu,x4e),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(E4e(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(T4e(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,S4e,{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(T4e(a)){if(a.tolerance!=null&&k9(s,a.tolerance))return this.handleCancel();if(k9(s,a.distance))return this.handleStart()}if(E4e(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()}},D4e={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,D4e,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 O4e={move:{name:`mousemove`},end:{name:`mouseup`}},k4e;(function(e){e[e.RightClick=2]=`RightClick`})(k4e||={});var A4e=class extends N9{constructor(e){super(e,O4e,a9(e.event.target))}};A4e.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===k4e.RightClick?!1:(r?.({event:n}),!0)}}];var F9={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},j4e=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(){}}};j4e.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 M4e(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=P4e({delta:d,disabled:!a}),[m,h]=S2e(),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}=p4e(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 N4e={x:{[E9.Backward]:!1,[E9.Forward]:!1},y:{[E9.Backward]:!1,[E9.Forward]:!1}};function P4e(e){let{delta:t,disabled:n}=e,r=d9(t);return l9(e=>{if(n||!r||!e)return N4e;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 F4e(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 I4e(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 L4e;(function(e){e.Optimized=`optimized`})(L4e||={});var R4e=new Map;function z4e(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 R4e;if(!t||t===R4e||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 B4e(e,t){return l9(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function V4e(e,t){return B4e(e,t)}function H4e(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 U4e(e){return new D9(S9(e),e)}function W4e(e,t,n){t===void 0&&(t=U4e);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=H4e({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 G4e(e){return Z2e(e,B4e(e))}var K4e=[];function q4e(e){let t=(0,C.useRef)(e),n=l9(n=>e?n&&n!==K4e&&e&&t.current&&e.parentNode===t.current.parentNode?n:C9(e):K4e,[e]);return(0,C.useEffect)(()=>{t.current=e},[e]),n}function J4e(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):h4e(e):x9,[e,t])}function Y4e(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 X4e(e){(0,C.useEffect)(()=>{if(!Q7)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 Z4e(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 Q4e(e){return(0,C.useMemo)(()=>e?i4e(e):null,[e])}var $4e=[];function e3e(e,t){t===void 0&&(t=S9);let[n]=e,r=Q4e(n?t9(n):null),[i,a]=(0,C.useState)($4e);function o(){a(()=>e.length?e.map(e=>u4e(e)?r:new D9(t(e),e)):$4e)}let s=z9({callback:o});return o9(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function t3e(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return r9(t)?t:e}function n3e(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(r9(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=t3e(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 r3e=[{sensor:P9,options:{}},{sensor:M9,options:{}}],i3e={current:{}},B9={draggable:{measure:r4e},droppable:{measure:r4e,strategy:R9.WhileDragging,frequency:L4e.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}},a3e={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},o3e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:b9,draggableNodes:new Map,over:null,measureDroppableContainers:b9},H9=(0,C.createContext)(o3e),s3e=(0,C.createContext)(a3e);function c3e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new V9}}}function l3e(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 u3e(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=D2e(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function d3e(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function f3e(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 p3e(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=Z2e(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=s4e(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var m3e=(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 h3e=(0,C.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=r3e,collisionDetection:o=Y2e,measuring:s,modifiers:c,...l}=e,[u,d]=(0,C.useReducer)(l3e,void 0,c3e),[f,p]=P2e(),[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??i3e,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=f3e(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=z4e(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=F4e(v,_),R=(0,C.useMemo)(()=>O?_9(O):null,[O]),ee=Te(),z=V4e(L,N.draggable.measure);p3e({activeNode:_==null?null:v.get(_),config:ee.layoutShiftCompensation,initialRect:z,measure:N.draggable.measure});let te=W4e(L,N.draggable.measure,z),B=W4e(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=n3e({measure:N.dragOverlay.measure}),ie=re.nodeRef.current??L,ae=g?re.rect??te:null,oe=!!(re.nodeRef.current&&re.rect),se=G4e(oe?null:te),ce=Q4e(ie?t9(ie):null),le=q4e(g?ne??L:null),ue=e3e(le),H=d3e(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=J4e(le),U=Y4e(fe),pe=Y4e(fe,[te]),me=m9(H,U),W=ae?$2e(ae,H):null,he=w&&W?o({active:w,collisionRect:W,droppableRects:P,droppableContainers:M,pointerCoordinates:de}):null,ge=W2e(he,`id`),[_e,ve]=(0,C.useState)(null),ye=X2e(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,Aa.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,Aa.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=I4e(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]));X4e(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,Aa.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,Aa.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]),M4e({...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(M2e.Provider,{value:p},C.createElement(H9.Provider,{value:we},C.createElement(s3e.Provider,{value:Ce},C.createElement(m3e.Provider,{value:ye},i)),C.createElement(u3e,{disabled:n?.restoreFocus===!1})),C.createElement(L2e,{...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}}}),g3e=(0,C.createContext)(null),_3e=`button`,v3e=`Draggable`;function y3e(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=p9(v3e),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,C.useContext)(H9),{role:p=_3e,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,C.useContext)(g?m3e:g3e),[v,y]=u9(),[b,x]=u9(),S=Z4e(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===_3e?!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 b3e(){return(0,C.useContext)(s3e)}var x3e=`Droppable`,S3e={timeout:25};function C3e(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=p9(x3e),{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}={...S3e,...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 w3e(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 T3e(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 E3e(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var D3e=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},O3e=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=k3e(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 k3e(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 A3e=`Sortable`,j3e=C.createContext({activeIndex:-1,containerId:A3e,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:D3e,disabled:{draggable:!1,droppable:!1}});function M3e(e){let{children:t,id:n,items:r,strategy:i=D3e,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=b3e(),d=p9(A3e,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=!T3e(p,_.current),y=g!==-1&&h===-1||v,b=E3e(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:w3e(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return C.createElement(j3e.Provider,{value:x},t)}var N3e=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return W9(n,r,i).indexOf(t)},P3e=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},F3e={duration:200,easing:`ease`},I3e=`transform`,L3e=v9.Transition.toString({property:I3e,duration:0,easing:`linear`}),R3e={roleDescription:`sortable`};function z3e(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 B3e(e){let{animateLayoutChanges:t=P3e,attributes:n,disabled:r,data:i,getNewIndex:a=N3e,id:o,strategy:s,resizeObserverConfig:c,transition:l=F3e}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,C.useContext)(j3e),y=V3e(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}=C3e({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}=y3e({id:o,data:x,attributes:{...R3e,...n},disabled:y.draggable}),R=x2e(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=z3e({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 L3e;if(!(te&&!g9(k)||!l)&&(ee||ae))return v9.Transition.toString({...l,property:I3e})}}function V3e(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 H3e=[j9.Down,j9.Right,j9.Up,j9.Left],U3e=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(H3e.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=q2e({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=W2e(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=W3e(e,t),a=G3e(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 W3e(e,t){return!q9(e)||!q9(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function G3e(e,t){return!q9(e)||!q9(t)||!W3e(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var K3e=({bridge:e,index:t})=>{let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=B3e({id:e.id}),[c,l]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{TE(e.id).then(l)},[e.id]),(0,G.jsx)(Sv,{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)(Tv,{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)(Ghe,{})}),(0,G.jsx)(Nv,{label:t+1,size:`small`,color:`primary`,sx:{minWidth:32,fontWeight:`bold`}}),c?(0,G.jsx)(Z,{component:`img`,src:EE(e.id),alt:e.name,sx:{width:40,height:40,borderRadius:`50%`,objectFit:`cover`,boxShadow:2}}):(0,G.jsx)(jb,{sx:{bgcolor:ME(e),width:40,height:40,boxShadow:2},children:(0,G.jsx)(jE(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]})]})]})})},q3e=()=>{let{t:e}=Ts(),t=ey(),{content:n,isLoading:r}=FT(),i=fhe(),[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=z2e(R2e(P9),R2e(M9,{coordinateGetter:U3e})),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)(Yv,{spacing:3,children:[(0,G.jsx)($v,{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)(_v,{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)(Wh,{severity:`info`,action:(0,G.jsx)(xv,{color:`inherit`,size:`small`,startIcon:(0,G.jsx)(hE,{}),onClick:d,children:e(`startup.saveChanges`)}),children:e(`startup.unsavedChanges`)}),(0,G.jsx)(h3e,{sensors:l,collisionDetection:K2e,onDragEnd:u,children:(0,G.jsx)(M3e,{items:f,strategy:O3e,children:(0,G.jsx)(Yv,{spacing:1,children:a.map((e,t)=>(0,G.jsx)(K3e,{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)(xv,{variant:`contained`,startIcon:(0,G.jsx)(hE,{}),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`,standaloneDevices:`/standalone-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`}},J3e=[{path:``,element:(0,G.jsx)(kre,{}),children:[{path:``,element:(0,G.jsx)(p_e,{})},{path:Y9.bridges,element:(0,G.jsx)(o_e,{})},{path:Y9.createBridge,element:(0,G.jsx)(oJe,{})},{path:Y9.areaSetup,element:(0,G.jsx)(Oae,{})},{path:Y9.bridge(`:bridgeId`),element:(0,G.jsx)(Ohe,{})},{path:Y9.editBridge(`:bridgeId`),element:(0,G.jsx)(sJe,{})},{path:Y9.devices,element:(0,G.jsx)(F_e,{})},{path:Y9.standaloneDevices,element:(0,G.jsx)(b2e,{})},{path:Y9.networkMap,element:(0,G.jsx)(B0e,{})},{path:Y9.health,element:(0,G.jsx)(DJe,{})},{path:Y9.labels,element:(0,G.jsx)(jJe,{})},{path:Y9.lockCredentials,element:(0,G.jsx)(LJe,{})},{path:Y9.plugins,element:(0,G.jsx)(l2e,{})},{path:Y9.settings,element:(0,G.jsx)(_2e,{})},{path:Y9.startup,element:(0,G.jsx)(q3e,{})},{path:`*`,element:(0,G.jsx)(RJe,{})}]}],Y3e=O_({items:{isInitialized:!1,isLoading:!1}},e=>{e.addCase(J_.pending,e=>{e.items.isLoading=!0}).addCase(J_.rejected,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=void 0,e.items.error=t.error}).addCase(J_.fulfilled,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(Y_.fulfilled,(e,t)=>{e.items.content?.push(t.payload)}).addCase(Z_.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(Q_.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(X_.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($_,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(ev,(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}})}),X3e=O_({byBridge:{}},e=>{e.addCase(BT.pending,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(BT.rejected,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(BT.fulfilled,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)})}),X9=O_({isInitialized:!1,isLoading:!1,content:void 0,error:void 0},e=>{e.addCase(BT.pending,e=>{e.isLoading=!0}).addCase(BT.rejected,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=void 0,e.error=t.error}).addCase(BT.fulfilled,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=t.payload,e.error=void 0})}),Z3e=cre({reducer:{bridges:Y3e,devices:X3e}}),Z9=Ap({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 Q3e(e){return Yd(`MuiToolbar`,e)}Xd(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var $3e=e=>{let{classes:t,disableGutters:n,variant:r}=e;return Tp({root:[`root`,!n&&`gutters`,r]},Q3e,t)},e6e=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}]}))),t6e=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)(e6e,{as:i,className:K($3e(c).root,r),ref:t,ownerState:c,...s})}),n6e=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)(Cb,{color:`error`,sx:{fontSize:64}}),(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:Ks.t(`errorBoundary.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,textAlign:`center`,maxWidth:480,children:this.state.error?.message??Ks.t(`errorBoundary.fallbackMessage`)}),(0,G.jsx)(xv,{variant:`contained`,onClick:()=>{this.setState({hasError:!1,error:null}),window.location.reload()},children:Ks.t(`errorBoundary.reload`)})]}):this.props.children}};function r6e(e){return Yd(`MuiFab`,e)}var i6e=Xd(`MuiFab`,[`root`,`primary`,`secondary`,`extended`,`circular`,`focusVisible`,`disabled`,`colorInherit`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`info`,`error`,`warning`,`success`]),a6e=e=>{let{color:t,variant:n,classes:r,size:i}=e,a=Tp({root:[`root`,n,`size${Y(i)}`,t===`inherit`?`colorInherit`:t]},r6e,r);return{...r,...a}},o6e=J(Ph,{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`},[`&.${i6e.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(Wm([`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})=>({[`&.${i6e.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}))),s6e=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=a6e(p);return(0,G.jsx)(o6e,{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})}),c6e=[{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:`hu`,flag:`🇭🇺`,name:`Magyar`},{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:`Русский`}],l6e=`hamh-custom-languages`;function u6e(){try{let e=localStorage.getItem(l6e);return e?JSON.parse(e).map(e=>({code:e.code,flag:`🌐`,name:e.name})):[]}catch{return[]}}var d6e=`https://github.com/RiDDiX/home-assistant-matter-hub/issues/new?labels=translation&title=Translation+improvement`;function f6e(){let{t:e,i18n:t}=Ts(),[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(null),a=(0,C.useMemo)(()=>[...c6e,...u6e()],[]),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)(qh,{onClickAway:(0,C.useCallback)(()=>{r(!1)},[]),children:(0,G.jsxs)(Z,{children:[(0,G.jsx)(s6e,{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)(Qhe,{})}),(0,G.jsx)(fb,{open:n,anchorEl:i.current,placement:`top-end`,transition:!0,sx:{zIndex:1300},children:({TransitionProps:t})=>(0,G.jsx)(Rb,{...t,timeout:200,children:(0,G.jsxs)(Gm,{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)(Xb,{}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`flex-start`,gap:.75,px:2,py:1},children:[(0,G.jsx)(ty,{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)(Qv,{href:d6e,target:`_blank`,rel:`noopener`,sx:{fontSize:`inherit`},children:e(`languageSwitcher.contribute`)})]})]})]})})})]})})}var p6e={name:`home-assistant-matter-hub`,description:``,version:`2.1.0-alpha.761`,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.17.3`,"@matter/nodejs":`0.17.3`,"@matter/general":`0.17.3`,"@matter/types":`0.17.3`,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`,werift:`0.22.4`,ws:`8.21.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 m6e(){let e=`2.1.0-alpha.761`,[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!==t:!1,[t]);return(0,C.useMemo)(()=>({name:p6e.name,version:t??e,frontendVersion:e,backendVersion:t,versionMismatch:r}),[t,r])}var h6e=()=>{let{t:e}=Ts(),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)(Xb,{sx:{mt:4,mb:4}}),(0,G.jsx)(Hv,{container:!0,spacing:2,justifyContent:`center`,children:t.map((e,t)=>(0,G.jsx)(Hv,{size:{xs:12,sm:`auto`},children:(0,G.jsx)(xv,{fullWidth:!0,size:`small`,variant:`outlined`,component:Qv,href:e.url,target:`_blank`,children:e.name})},t.toString()))})]})};function g6e(e){return Yd(`MuiAppBar`,e)}Xd(`MuiAppBar`,[`root`,`positionFixed`,`positionAbsolute`,`positionSticky`,`positionStatic`,`positionRelative`,`colorDefault`,`colorPrimary`,`colorSecondary`,`colorInherit`,`colorTransparent`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`]);var _6e=e=>{let{color:t,position:n,classes:r}=e;return Tp({root:[`root`,`color${Y(t)}`,`position${Y(n)}`]},g6e,r)},v6e=(e,t)=>e?`${e.replace(`)`,``)}, ${t})`:t,y6e=J(Gm,{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(Wm([`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?v6e(e.vars.palette.AppBar.darkBg,`var(--AppBar-background)`):null,color:e.vars?v6e(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`})}}]}))),b6e=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)(y6e,{square:!0,component:`header`,ownerState:c,elevation:4,className:K(_6e(c).root,r,o===`fixed`&&`mui-fixed`),ref:t,...s})}),x6e={visibility:`hidden`};function S6e(e,t,n){let r=n&&n.getBoundingClientRect(),i=th(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 C6e(e){return typeof e==`function`?e():e}function Q9(e,t,n){let r=S6e(e,t,C6e(n));r&&(t.style.transform=r)}var w6e=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=lh(Gh(s),x,t),w=Yh(x,(e,t)=>{Q9(l,e,c),Jh(e),f&&f(e,t)}),T=Yh(x,(e,t)=>{let r=Zh({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=Yh(x,p),D=Yh(x,_),O=Yh(x,e=>{let t=Zh({timeout:y,style:v,easing:u},{mode:`exit`});e.style.transition=n.transitions.create(`transform`,t),Q9(l,e,c),h&&h(e)}),k=Yh(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=Xm(()=>{x.current&&Q9(l,x.current,c)}),t=th(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)(Th,{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}:x6e:v&&s.props.style?{...v,...s.props.style}:v||s.props.style,C.cloneElement(s,{ref:S,style:r,...n})}})});function T6e(e){return Yd(`MuiDrawer`,e)}Xd(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`paperAnchorLeft`,`paperAnchorRight`,`paperAnchorTop`,`paperAnchorBottom`,`paperAnchorDockedLeft`,`paperAnchorDockedRight`,`paperAnchorDockedTop`,`paperAnchorDockedBottom`,`modal`]);var E6e=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},D6e=e=>{let{classes:t,anchor:n,variant:r}=e;return Tp({root:[`root`,`anchor${Y(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`,`paperAnchor${Y(n)}`,r!==`temporary`&&`paperAnchorDocked${Y(n)}`]},T6e,t)},O6e=J(Hb,{name:`MuiDrawer`,slot:`Root`,overridesResolver:E6e})(Fm(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),k6e=J(`div`,{shouldForwardProp:Dm,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:E6e})({flex:`0 0 auto`}),A6e=J(Gm,{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}`}}]}))),j6e={left:`right`,right:`left`,top:`down`,bottom:`up`};function M6e(e){return[`left`,`right`].includes(e)}function N6e({direction:e},t){return e===`rtl`&&M6e(t)?j6e[t]:t}var P6e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiDrawer`}),r=wm(),i=Wf(),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=N6e({direction:i?`rtl`:`ltr`},o),D=o,O={...n,anchor:D,elevation:u,open:h,variant:b,...w},k=D6e(O),A={slots:{transition:v,...x},slotProps:{paper:g,transition:_,...S,backdrop:uh(S.backdrop||{...s,...f},{transitionDuration:y})}},[j,M]=Um(`root`,{ref:t,elementType:O6e,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]=Um(`paper`,{elementType:A6e,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]=Um(`docked`,{elementType:k6e,ref:t,className:K(k.root,k.docked,l),ownerState:O,externalForwardedProps:A,additionalProps:w}),[L,R]=Um(`transition`,{elementType:w6e,ownerState:O,externalForwardedProps:A,additionalProps:{in:h,direction:j6e[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})}),F6e=vf({themeId:Cm}),I6e={error:Ox,warn:ny,info:Tb,debug:XT},L6e=({open:e,onClose:t})=>{let{t:n}=Ts(),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)(I6e[e]||Tb,{sx:{fontSize:16,color:i[e]}});return(0,G.jsxs)(Gb,{open:e,onClose:t,maxWidth:`lg`,fullWidth:!0,children:[(0,G.jsxs)(Jb,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(XT,{}),n(`logs.title`),(0,G.jsx)(Z,{sx:{flexGrow:1}}),(0,G.jsx)(vb,{title:n(`logs.autoRefresh`),children:(0,G.jsx)(Nv,{label:p?`Auto`:`Manual`,color:p?`success`:`default`,size:`small`,onClick:()=>m(!p),sx:{cursor:`pointer`}})}),(0,G.jsx)(Vh,{onClick:t,children:(0,G.jsx)($T,{})})]}),(0,G.jsxs)(qb,{children:[(0,G.jsx)(Yv,{spacing:2,sx:{mb:2},children:(0,G.jsxs)(Yv,{direction:`row`,spacing:2,alignItems:`center`,children:[(0,G.jsxs)(Iv,{size:`small`,sx:{minWidth:200},children:[(0,G.jsx)(Ux,{children:n(`logs.logLevel`)}),(0,G.jsxs)(wS,{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)(Nv,{label:e.toUpperCase(),size:`small`,sx:{backgroundColor:i[e],color:`white`}},e))}),children:[(0,G.jsx)(TS,{value:`error`,children:n(`logs.error`)}),(0,G.jsx)(TS,{value:`warn`,children:n(`logs.warning`)}),(0,G.jsx)(TS,{value:`info`,children:n(`logs.info`)}),(0,G.jsx)(TS,{value:`debug`,children:n(`logs.debug`)})]})]}),(0,G.jsx)(OS,{size:`small`,placeholder:n(`logs.searchPlaceholder`),value:d,onChange:_,sx:{flexGrow:1}}),(0,G.jsx)(xv,{variant:`outlined`,onClick:h,children:n(`common.refresh`)}),(0,G.jsx)(xv,{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)(Yv,{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)(Nv,{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)(Kb,{children:(0,G.jsx)(xv,{onClick:t,children:n(`common.close`)})})]})};function R6e(){let{t:e}=Ts(),{isConnected:t}=iv(),[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)(vb,{title:d,arrow:!0,children:(0,G.jsx)(Nv,{icon:i||!s?(0,G.jsx)(Ox,{fontSize:`small`}):l?(0,G.jsx)(gv,{fontSize:`small`}):(0,G.jsx)(Ob,{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 z6e=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`})]})}),B6e=e=>{let t=m6e();return(0,G.jsxs)(Z,{component:da,to:Y9.dashboard,sx:{display:`flex`,alignItems:`center`,justifyContent:e.large?`flex-start`:`center`,flexGrow:1,textDecoration:`none`,color:`inherit`},children:[(0,G.jsx)(z6e,{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})]})},V6e=()=>{let e=F6e(`(min-width:600px)`),{mode:t,setMode:n}=Pm(),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(!1),s=Pr(),c=jr(),l=e=>e?e===`/`?c.pathname===`/`:c.pathname.startsWith(e):!1,u=()=>{n(t===`dark`?`light`:`dark`)},{t:d}=Ts(),f=[{label:d(`dashboard.title`),icon:(0,G.jsx)(iE,{}),to:Y9.dashboard},{label:d(`nav.bridges`),icon:(0,G.jsx)(aE,{}),to:Y9.bridges},{label:d(`nav.devices`),icon:(0,G.jsx)(xb,{}),to:Y9.devices},{label:d(`nav.standaloneDevices`,`Standalone Devices`),icon:(0,G.jsx)(cge,{}),to:Y9.standaloneDevices},{label:d(`nav.networkMap`),icon:(0,G.jsx)(WT,{}),to:Y9.networkMap},{label:d(`nav.startupOrder`),icon:(0,G.jsx)(_v,{}),to:Y9.startup},{label:d(`nav.lockCredentials`),icon:(0,G.jsx)(CT,{}),to:Y9.lockCredentials},{label:d(`nav.filterReference`),icon:(0,G.jsx)(oE,{}),to:Y9.labels},{label:`Plugins`,icon:(0,G.jsx)(nE,{}),to:Y9.plugins},{label:d(`nav.settings`),icon:(0,G.jsx)(MT,{}),to:Y9.settings},{label:d(t===`dark`?`nav.lightMode`:`nav.darkMode`),icon:t===`dark`?(0,G.jsx)(tge,{}):(0,G.jsx)(Hhe,{}),onClick:u},{label:d(`nav.systemLogs`),icon:(0,G.jsx)(XT,{}),onClick:()=>i(!0)},{label:d(`nav.health`),icon:(0,G.jsx)(Mx,{}),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)(b6e,{sx:{height:`72px`},children:(0,G.jsx)(t6e,{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)(B6e,{large:e}),e?(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[f.map(e=>e.to?(0,G.jsx)(vb,{title:e.label,children:(0,G.jsx)(Vh,{component:da,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)(vb,{title:e.label,children:(0,G.jsx)(Vh,{onClick:e.onClick,sx:{color:`inherit`},children:e.icon})},e.label)),(0,G.jsx)(R6e,{})]}):(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(R6e,{}),(0,G.jsx)(Vh,{onClick:()=>o(!0),sx:{color:`inherit`},children:(0,G.jsx)(nge,{})})]})]})})}),(0,G.jsx)(P6e,{anchor:`right`,open:a,onClose:()=>o(!1),children:(0,G.jsx)(oy,{sx:{width:250},children:f.map(e=>(0,G.jsxs)(Gae,{selected:l(e.to),onClick:()=>p(e),children:[(0,G.jsx)(dy,{children:e.icon}),(0,G.jsx)(py,{primary:e.label})]},e.label))})}),(0,G.jsx)(L6e,{open:r,onClose:()=>i(!1)})]})},H6e=()=>{let{versionMismatch:e,frontendVersion:t,backendVersion:n}=m6e(),{isConnected:r}=iv();return(0,G.jsxs)(Z,{children:[(0,G.jsx)(V6e,{}),(0,G.jsx)(t6e,{}),e&&(0,G.jsxs)(Wh,{severity:`warning`,variant:`filled`,sx:{borderRadius:0},action:(0,G.jsx)(xv,{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)(Wh,{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)(n6e,{children:(0,G.jsx)(vi,{})})}),(0,G.jsx)(h6e,{}),(0,G.jsx)(f6e,{})]})},U6e=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 W6e=sa([{path:`/`,element:(0,G.jsx)(H6e,{}),children:J3e}],{basename:$9});(0,S.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(C.StrictMode,{children:(0,G.jsx)(L,{store:Z3e,children:(0,G.jsxs)(ite,{theme:U6e,children:[(0,G.jsx)(Qee,{}),(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)(Ore,{children:(0,G.jsx)(bne,{children:(0,G.jsx)(ja,{router:W6e})})})]})})}));
469
+ `},I2e={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 L2e(e){let{announcements:t=I2e,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=F2e}=e,{announce:a,announcement:o}=j2e(),s=p9(`DndLiveRegion`),[c,l]=(0,C.useState)(!1);if((0,C.useEffect)(()=>{l(!0)},[]),N2e((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(k2e,{id:r,value:i.draggable}),C.createElement(A2e,{id:s,announcement:o}));return n?(0,Aa.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 R2e(e,t){return(0,C.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function z2e(){var e=[...arguments];return(0,C.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var x9=Object.freeze({x:0,y:0});function B2e(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function V2e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function H2e(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function U2e(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 W2e(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function G2e(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 K2e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=G2e(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=B2e(G2e(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(V2e)},q2e=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=U2e(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=U2e(r),o=i.reduce((e,t,r)=>e+B2e(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(V2e)};function J2e(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 Y2e=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=J2e(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(H2e)};function X2e(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Z2e(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:x9}function Q2e(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 $2e=Q2e(1);function e4e(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 t4e(e,t,n){let r=e4e(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 n4e={ignoreTransform:!1};function S9(e,t){t===void 0&&(t=n4e);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=t9(e).getComputedStyle(e);t&&(n=t4e(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 r4e(e){return S9(e,{ignoreTransform:!0})}function i4e(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function a4e(e,t){return t===void 0&&(t=t9(e).getComputedStyle(e)),t.position===`fixed`}function o4e(e,t){t===void 0&&(t=t9(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(n9(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!r9(i)||i9(i)||n.includes(i))return n;let a=t9(e).getComputedStyle(i);return i!==e&&o4e(i,a)&&n.push(i),a4e(i,a)?n:r(i.parentNode)}return e?r(e):n}function s4e(e){let[t]=C9(e,1);return t??null}function w9(e){return!Q7||!e?null:$7(e)?e:e9(e)?n9(e)||e===a9(e).scrollingElement?window:r9(e)?e:null:null}function c4e(e){return $7(e)?e.scrollX:e.scrollLeft}function l4e(e){return $7(e)?e.scrollY:e.scrollTop}function T9(e){return{x:c4e(e),y:l4e(e)}}var E9;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(E9||={});function u4e(e){return!Q7||!e?!1:e===document.scrollingElement}function d4e(e){let t={x:0,y:0},n=u4e(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 f4e={x:.2,y:.2};function p4e(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=f4e);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=d4e(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 m4e(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 h4e(e){return e.reduce((e,t)=>m9(e,T9(t)),x9)}function g4e(e){return e.reduce((e,t)=>e+c4e(t),0)}function _4e(e){return e.reduce((e,t)=>e+l4e(t),0)}function v4e(e,t){if(t===void 0&&(t=S9),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);s4e(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var y4e=[[`x`,[`left`,`right`],g4e],[`y`,[`top`,`bottom`],_4e]],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=h4e(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of y4e)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 b4e(e){let{EventTarget:t}=t9(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 x4e(e){e.preventDefault()}function S4e(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 C4e={start:[j9.Space,j9.Enter],cancel:[j9.Esc],end:[j9.Space,j9.Enter,j9.Tab]},w4e=(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(t9(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&&v4e(n),t(x9)}handleKeyDown(e){if(g9(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=C4e,coordinateGetter:a=w4e,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}=d4e(n),p=m4e(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=C4e,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 T4e(e){return!!(e&&`distance`in e)}function E4e(e){return!!(e&&`delay`in e)}var N9=class{constructor(e,t,n){n===void 0&&(n=b4e(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(t9(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,x4e),this.windowListeners.add(A9.VisibilityChange,this.handleCancel),this.windowListeners.add(A9.ContextMenu,x4e),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(E4e(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(T4e(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,S4e,{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(T4e(a)){if(a.tolerance!=null&&k9(s,a.tolerance))return this.handleCancel();if(k9(s,a.distance))return this.handleStart()}if(E4e(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()}},D4e={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,D4e,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 O4e={move:{name:`mousemove`},end:{name:`mouseup`}},k4e;(function(e){e[e.RightClick=2]=`RightClick`})(k4e||={});var A4e=class extends N9{constructor(e){super(e,O4e,a9(e.event.target))}};A4e.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===k4e.RightClick?!1:(r?.({event:n}),!0)}}];var F9={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},j4e=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(){}}};j4e.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 M4e(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=P4e({delta:d,disabled:!a}),[m,h]=S2e(),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}=p4e(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 N4e={x:{[E9.Backward]:!1,[E9.Forward]:!1},y:{[E9.Backward]:!1,[E9.Forward]:!1}};function P4e(e){let{delta:t,disabled:n}=e,r=d9(t);return l9(e=>{if(n||!r||!e)return N4e;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 F4e(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 I4e(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 L4e;(function(e){e.Optimized=`optimized`})(L4e||={});var R4e=new Map;function z4e(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 R4e;if(!t||t===R4e||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 B4e(e,t){return l9(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function V4e(e,t){return B4e(e,t)}function H4e(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 U4e(e){return new D9(S9(e),e)}function W4e(e,t,n){t===void 0&&(t=U4e);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=H4e({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 G4e(e){return Z2e(e,B4e(e))}var K4e=[];function q4e(e){let t=(0,C.useRef)(e),n=l9(n=>e?n&&n!==K4e&&e&&t.current&&e.parentNode===t.current.parentNode?n:C9(e):K4e,[e]);return(0,C.useEffect)(()=>{t.current=e},[e]),n}function J4e(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):h4e(e):x9,[e,t])}function Y4e(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 X4e(e){(0,C.useEffect)(()=>{if(!Q7)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 Z4e(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 Q4e(e){return(0,C.useMemo)(()=>e?i4e(e):null,[e])}var $4e=[];function e3e(e,t){t===void 0&&(t=S9);let[n]=e,r=Q4e(n?t9(n):null),[i,a]=(0,C.useState)($4e);function o(){a(()=>e.length?e.map(e=>u4e(e)?r:new D9(t(e),e)):$4e)}let s=z9({callback:o});return o9(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function t3e(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return r9(t)?t:e}function n3e(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(r9(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=t3e(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 r3e=[{sensor:P9,options:{}},{sensor:M9,options:{}}],i3e={current:{}},B9={draggable:{measure:r4e},droppable:{measure:r4e,strategy:R9.WhileDragging,frequency:L4e.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}},a3e={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},o3e={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:b9,draggableNodes:new Map,over:null,measureDroppableContainers:b9},H9=(0,C.createContext)(o3e),s3e=(0,C.createContext)(a3e);function c3e(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new V9}}}function l3e(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 u3e(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=D2e(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function d3e(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function f3e(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 p3e(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=Z2e(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=s4e(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var m3e=(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 h3e=(0,C.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=r3e,collisionDetection:o=Y2e,measuring:s,modifiers:c,...l}=e,[u,d]=(0,C.useReducer)(l3e,void 0,c3e),[f,p]=P2e(),[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??i3e,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=f3e(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=z4e(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=F4e(v,_),R=(0,C.useMemo)(()=>O?_9(O):null,[O]),ee=Te(),z=V4e(L,N.draggable.measure);p3e({activeNode:_==null?null:v.get(_),config:ee.layoutShiftCompensation,initialRect:z,measure:N.draggable.measure});let te=W4e(L,N.draggable.measure,z),B=W4e(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=n3e({measure:N.dragOverlay.measure}),ie=re.nodeRef.current??L,ae=g?re.rect??te:null,oe=!!(re.nodeRef.current&&re.rect),se=G4e(oe?null:te),ce=Q4e(ie?t9(ie):null),le=q4e(g?ne??L:null),ue=e3e(le),H=d3e(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=J4e(le),U=Y4e(fe),pe=Y4e(fe,[te]),me=m9(H,U),W=ae?$2e(ae,H):null,he=w&&W?o({active:w,collisionRect:W,droppableRects:P,droppableContainers:M,pointerCoordinates:de}):null,ge=W2e(he,`id`),[_e,ve]=(0,C.useState)(null),ye=X2e(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,Aa.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,Aa.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=I4e(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]));X4e(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,Aa.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,Aa.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]),M4e({...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(M2e.Provider,{value:p},C.createElement(H9.Provider,{value:we},C.createElement(s3e.Provider,{value:Ce},C.createElement(m3e.Provider,{value:ye},i)),C.createElement(u3e,{disabled:n?.restoreFocus===!1})),C.createElement(L2e,{...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}}}),g3e=(0,C.createContext)(null),_3e=`button`,v3e=`Draggable`;function y3e(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=p9(v3e),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,C.useContext)(H9),{role:p=_3e,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,C.useContext)(g?m3e:g3e),[v,y]=u9(),[b,x]=u9(),S=Z4e(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===_3e?!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 b3e(){return(0,C.useContext)(s3e)}var x3e=`Droppable`,S3e={timeout:25};function C3e(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=p9(x3e),{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}={...S3e,...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 w3e(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 T3e(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 E3e(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var D3e=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},O3e=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=k3e(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 k3e(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 A3e=`Sortable`,j3e=C.createContext({activeIndex:-1,containerId:A3e,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:D3e,disabled:{draggable:!1,droppable:!1}});function M3e(e){let{children:t,id:n,items:r,strategy:i=D3e,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=b3e(),d=p9(A3e,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=!T3e(p,_.current),y=g!==-1&&h===-1||v,b=E3e(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:w3e(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return C.createElement(j3e.Provider,{value:x},t)}var N3e=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return W9(n,r,i).indexOf(t)},P3e=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},F3e={duration:200,easing:`ease`},I3e=`transform`,L3e=v9.Transition.toString({property:I3e,duration:0,easing:`linear`}),R3e={roleDescription:`sortable`};function z3e(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 B3e(e){let{animateLayoutChanges:t=P3e,attributes:n,disabled:r,data:i,getNewIndex:a=N3e,id:o,strategy:s,resizeObserverConfig:c,transition:l=F3e}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,C.useContext)(j3e),y=V3e(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}=C3e({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}=y3e({id:o,data:x,attributes:{...R3e,...n},disabled:y.draggable}),R=x2e(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=z3e({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 L3e;if(!(te&&!g9(k)||!l)&&(ee||ae))return v9.Transition.toString({...l,property:I3e})}}function V3e(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 H3e=[j9.Down,j9.Right,j9.Up,j9.Left],U3e=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(H3e.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=q2e({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=W2e(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=W3e(e,t),a=G3e(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 W3e(e,t){return!q9(e)||!q9(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function G3e(e,t){return!q9(e)||!q9(t)||!W3e(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var K3e=({bridge:e,index:t})=>{let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=B3e({id:e.id}),[c,l]=(0,C.useState)(!1);return(0,C.useEffect)(()=>{TE(e.id).then(l)},[e.id]),(0,G.jsx)(Sv,{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)(Tv,{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)(Ghe,{})}),(0,G.jsx)(Nv,{label:t+1,size:`small`,color:`primary`,sx:{minWidth:32,fontWeight:`bold`}}),c?(0,G.jsx)(Z,{component:`img`,src:EE(e.id),alt:e.name,sx:{width:40,height:40,borderRadius:`50%`,objectFit:`cover`,boxShadow:2}}):(0,G.jsx)(jb,{sx:{bgcolor:ME(e),width:40,height:40,boxShadow:2},children:(0,G.jsx)(jE(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]})]})]})})},q3e=()=>{let{t:e}=Ts(),t=ey(),{content:n,isLoading:r}=FT(),i=fhe(),[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=z2e(R2e(P9),R2e(M9,{coordinateGetter:U3e})),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)(Yv,{spacing:3,children:[(0,G.jsx)($v,{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)(_v,{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)(Wh,{severity:`info`,action:(0,G.jsx)(xv,{color:`inherit`,size:`small`,startIcon:(0,G.jsx)(hE,{}),onClick:d,children:e(`startup.saveChanges`)}),children:e(`startup.unsavedChanges`)}),(0,G.jsx)(h3e,{sensors:l,collisionDetection:K2e,onDragEnd:u,children:(0,G.jsx)(M3e,{items:f,strategy:O3e,children:(0,G.jsx)(Yv,{spacing:1,children:a.map((e,t)=>(0,G.jsx)(K3e,{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)(xv,{variant:`contained`,startIcon:(0,G.jsx)(hE,{}),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`,standaloneDevices:`/standalone-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`}},J3e=[{path:``,element:(0,G.jsx)(kre,{}),children:[{path:``,element:(0,G.jsx)(p_e,{})},{path:Y9.bridges,element:(0,G.jsx)(o_e,{})},{path:Y9.createBridge,element:(0,G.jsx)(oJe,{})},{path:Y9.areaSetup,element:(0,G.jsx)(Oae,{})},{path:Y9.bridge(`:bridgeId`),element:(0,G.jsx)(Ohe,{})},{path:Y9.editBridge(`:bridgeId`),element:(0,G.jsx)(sJe,{})},{path:Y9.devices,element:(0,G.jsx)(F_e,{})},{path:Y9.standaloneDevices,element:(0,G.jsx)(b2e,{})},{path:Y9.networkMap,element:(0,G.jsx)(B0e,{})},{path:Y9.health,element:(0,G.jsx)(DJe,{})},{path:Y9.labels,element:(0,G.jsx)(jJe,{})},{path:Y9.lockCredentials,element:(0,G.jsx)(LJe,{})},{path:Y9.plugins,element:(0,G.jsx)(l2e,{})},{path:Y9.settings,element:(0,G.jsx)(_2e,{})},{path:Y9.startup,element:(0,G.jsx)(q3e,{})},{path:`*`,element:(0,G.jsx)(RJe,{})}]}],Y3e=O_({items:{isInitialized:!1,isLoading:!1}},e=>{e.addCase(J_.pending,e=>{e.items.isLoading=!0}).addCase(J_.rejected,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=void 0,e.items.error=t.error}).addCase(J_.fulfilled,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(Y_.fulfilled,(e,t)=>{e.items.content?.push(t.payload)}).addCase(Z_.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(Q_.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(X_.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($_,(e,t)=>{e.items.isInitialized=!0,e.items.isLoading=!1,e.items.content=t.payload,e.items.error=void 0}).addCase(ev,(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}})}),X3e=O_({byBridge:{}},e=>{e.addCase(BT.pending,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(BT.rejected,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)}).addCase(BT.fulfilled,(e,t)=>{e.byBridge[t.meta.arg]=X9(e.byBridge[t.meta.arg],t)})}),X9=O_({isInitialized:!1,isLoading:!1,content:void 0,error:void 0},e=>{e.addCase(BT.pending,e=>{e.isLoading=!0}).addCase(BT.rejected,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=void 0,e.error=t.error}).addCase(BT.fulfilled,(e,t)=>{e.isInitialized=!0,e.isLoading=!1,e.content=t.payload,e.error=void 0})}),Z3e=cre({reducer:{bridges:Y3e,devices:X3e}}),Z9=Ap({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 Q3e(e){return Yd(`MuiToolbar`,e)}Xd(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var $3e=e=>{let{classes:t,disableGutters:n,variant:r}=e;return Tp({root:[`root`,!n&&`gutters`,r]},Q3e,t)},e6e=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}]}))),t6e=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)(e6e,{as:i,className:K($3e(c).root,r),ref:t,ownerState:c,...s})}),n6e=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)(Cb,{color:`error`,sx:{fontSize:64}}),(0,G.jsx)(Q,{variant:`h5`,fontWeight:600,children:Ks.t(`errorBoundary.title`)}),(0,G.jsx)(Q,{variant:`body2`,color:`text.secondary`,textAlign:`center`,maxWidth:480,children:this.state.error?.message??Ks.t(`errorBoundary.fallbackMessage`)}),(0,G.jsx)(xv,{variant:`contained`,onClick:()=>{this.setState({hasError:!1,error:null}),window.location.reload()},children:Ks.t(`errorBoundary.reload`)})]}):this.props.children}};function r6e(e){return Yd(`MuiFab`,e)}var i6e=Xd(`MuiFab`,[`root`,`primary`,`secondary`,`extended`,`circular`,`focusVisible`,`disabled`,`colorInherit`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`info`,`error`,`warning`,`success`]),a6e=e=>{let{color:t,variant:n,classes:r,size:i}=e,a=Tp({root:[`root`,n,`size${Y(i)}`,t===`inherit`?`colorInherit`:t]},r6e,r);return{...r,...a}},o6e=J(Ph,{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`},[`&.${i6e.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(Wm([`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})=>({[`&.${i6e.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}))),s6e=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=a6e(p);return(0,G.jsx)(o6e,{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})}),c6e=[{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:`hu`,flag:`🇭🇺`,name:`Magyar`},{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:`Русский`}],l6e=`hamh-custom-languages`;function u6e(){try{let e=localStorage.getItem(l6e);return e?JSON.parse(e).map(e=>({code:e.code,flag:`🌐`,name:e.name})):[]}catch{return[]}}var d6e=`https://github.com/RiDDiX/home-assistant-matter-hub/issues/new?labels=translation&title=Translation+improvement`;function f6e(){let{t:e,i18n:t}=Ts(),[n,r]=(0,C.useState)(!1),i=(0,C.useRef)(null),a=(0,C.useMemo)(()=>[...c6e,...u6e()],[]),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)(qh,{onClickAway:(0,C.useCallback)(()=>{r(!1)},[]),children:(0,G.jsxs)(Z,{children:[(0,G.jsx)(s6e,{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)(Qhe,{})}),(0,G.jsx)(fb,{open:n,anchorEl:i.current,placement:`top-end`,transition:!0,sx:{zIndex:1300},children:({TransitionProps:t})=>(0,G.jsx)(Rb,{...t,timeout:200,children:(0,G.jsxs)(Gm,{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)(Xb,{}),(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`flex-start`,gap:.75,px:2,py:1},children:[(0,G.jsx)(ty,{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)(Qv,{href:d6e,target:`_blank`,rel:`noopener`,sx:{fontSize:`inherit`},children:e(`languageSwitcher.contribute`)})]})]})]})})})]})})}var p6e={name:`home-assistant-matter-hub`,description:``,version:`2.1.0-alpha.763`,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.17.3`,"@matter/nodejs":`0.17.3`,"@matter/general":`0.17.3`,"@matter/types":`0.17.3`,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`,werift:`0.22.4`,ws:`8.21.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 m6e(){let e=`2.1.0-alpha.763`,[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!==t:!1,[t]);return(0,C.useMemo)(()=>({name:p6e.name,version:t??e,frontendVersion:e,backendVersion:t,versionMismatch:r}),[t,r])}var h6e=()=>{let{t:e}=Ts(),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)(Xb,{sx:{mt:4,mb:4}}),(0,G.jsx)(Hv,{container:!0,spacing:2,justifyContent:`center`,children:t.map((e,t)=>(0,G.jsx)(Hv,{size:{xs:12,sm:`auto`},children:(0,G.jsx)(xv,{fullWidth:!0,size:`small`,variant:`outlined`,component:Qv,href:e.url,target:`_blank`,children:e.name})},t.toString()))})]})};function g6e(e){return Yd(`MuiAppBar`,e)}Xd(`MuiAppBar`,[`root`,`positionFixed`,`positionAbsolute`,`positionSticky`,`positionStatic`,`positionRelative`,`colorDefault`,`colorPrimary`,`colorSecondary`,`colorInherit`,`colorTransparent`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`]);var _6e=e=>{let{color:t,position:n,classes:r}=e;return Tp({root:[`root`,`color${Y(t)}`,`position${Y(n)}`]},g6e,r)},v6e=(e,t)=>e?`${e.replace(`)`,``)}, ${t})`:t,y6e=J(Gm,{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(Wm([`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?v6e(e.vars.palette.AppBar.darkBg,`var(--AppBar-background)`):null,color:e.vars?v6e(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`})}}]}))),b6e=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)(y6e,{square:!0,component:`header`,ownerState:c,elevation:4,className:K(_6e(c).root,r,o===`fixed`&&`mui-fixed`),ref:t,...s})}),x6e={visibility:`hidden`};function S6e(e,t,n){let r=n&&n.getBoundingClientRect(),i=th(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 C6e(e){return typeof e==`function`?e():e}function Q9(e,t,n){let r=S6e(e,t,C6e(n));r&&(t.style.transform=r)}var w6e=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=lh(Gh(s),x,t),w=Yh(x,(e,t)=>{Q9(l,e,c),Jh(e),f&&f(e,t)}),T=Yh(x,(e,t)=>{let r=Zh({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=Yh(x,p),D=Yh(x,_),O=Yh(x,e=>{let t=Zh({timeout:y,style:v,easing:u},{mode:`exit`});e.style.transition=n.transitions.create(`transform`,t),Q9(l,e,c),h&&h(e)}),k=Yh(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=Xm(()=>{x.current&&Q9(l,x.current,c)}),t=th(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)(Th,{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}:x6e:v&&s.props.style?{...v,...s.props.style}:v||s.props.style,C.cloneElement(s,{ref:S,style:r,...n})}})});function T6e(e){return Yd(`MuiDrawer`,e)}Xd(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`paperAnchorLeft`,`paperAnchorRight`,`paperAnchorTop`,`paperAnchorBottom`,`paperAnchorDockedLeft`,`paperAnchorDockedRight`,`paperAnchorDockedTop`,`paperAnchorDockedBottom`,`modal`]);var E6e=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},D6e=e=>{let{classes:t,anchor:n,variant:r}=e;return Tp({root:[`root`,`anchor${Y(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`,`paperAnchor${Y(n)}`,r!==`temporary`&&`paperAnchorDocked${Y(n)}`]},T6e,t)},O6e=J(Hb,{name:`MuiDrawer`,slot:`Root`,overridesResolver:E6e})(Fm(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),k6e=J(`div`,{shouldForwardProp:Dm,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:E6e})({flex:`0 0 auto`}),A6e=J(Gm,{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}`}}]}))),j6e={left:`right`,right:`left`,top:`down`,bottom:`up`};function M6e(e){return[`left`,`right`].includes(e)}function N6e({direction:e},t){return e===`rtl`&&M6e(t)?j6e[t]:t}var P6e=C.forwardRef(function(e,t){let n=km({props:e,name:`MuiDrawer`}),r=wm(),i=Wf(),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=N6e({direction:i?`rtl`:`ltr`},o),D=o,O={...n,anchor:D,elevation:u,open:h,variant:b,...w},k=D6e(O),A={slots:{transition:v,...x},slotProps:{paper:g,transition:_,...S,backdrop:uh(S.backdrop||{...s,...f},{transitionDuration:y})}},[j,M]=Um(`root`,{ref:t,elementType:O6e,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]=Um(`paper`,{elementType:A6e,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]=Um(`docked`,{elementType:k6e,ref:t,className:K(k.root,k.docked,l),ownerState:O,externalForwardedProps:A,additionalProps:w}),[L,R]=Um(`transition`,{elementType:w6e,ownerState:O,externalForwardedProps:A,additionalProps:{in:h,direction:j6e[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})}),F6e=vf({themeId:Cm}),I6e={error:Ox,warn:ny,info:Tb,debug:XT},L6e=({open:e,onClose:t})=>{let{t:n}=Ts(),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)(I6e[e]||Tb,{sx:{fontSize:16,color:i[e]}});return(0,G.jsxs)(Gb,{open:e,onClose:t,maxWidth:`lg`,fullWidth:!0,children:[(0,G.jsxs)(Jb,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,G.jsx)(XT,{}),n(`logs.title`),(0,G.jsx)(Z,{sx:{flexGrow:1}}),(0,G.jsx)(vb,{title:n(`logs.autoRefresh`),children:(0,G.jsx)(Nv,{label:p?`Auto`:`Manual`,color:p?`success`:`default`,size:`small`,onClick:()=>m(!p),sx:{cursor:`pointer`}})}),(0,G.jsx)(Vh,{onClick:t,children:(0,G.jsx)($T,{})})]}),(0,G.jsxs)(qb,{children:[(0,G.jsx)(Yv,{spacing:2,sx:{mb:2},children:(0,G.jsxs)(Yv,{direction:`row`,spacing:2,alignItems:`center`,children:[(0,G.jsxs)(Iv,{size:`small`,sx:{minWidth:200},children:[(0,G.jsx)(Ux,{children:n(`logs.logLevel`)}),(0,G.jsxs)(wS,{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)(Nv,{label:e.toUpperCase(),size:`small`,sx:{backgroundColor:i[e],color:`white`}},e))}),children:[(0,G.jsx)(TS,{value:`error`,children:n(`logs.error`)}),(0,G.jsx)(TS,{value:`warn`,children:n(`logs.warning`)}),(0,G.jsx)(TS,{value:`info`,children:n(`logs.info`)}),(0,G.jsx)(TS,{value:`debug`,children:n(`logs.debug`)})]})]}),(0,G.jsx)(OS,{size:`small`,placeholder:n(`logs.searchPlaceholder`),value:d,onChange:_,sx:{flexGrow:1}}),(0,G.jsx)(xv,{variant:`outlined`,onClick:h,children:n(`common.refresh`)}),(0,G.jsx)(xv,{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)(Yv,{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)(Nv,{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)(Kb,{children:(0,G.jsx)(xv,{onClick:t,children:n(`common.close`)})})]})};function R6e(){let{t:e}=Ts(),{isConnected:t}=iv(),[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)(vb,{title:d,arrow:!0,children:(0,G.jsx)(Nv,{icon:i||!s?(0,G.jsx)(Ox,{fontSize:`small`}):l?(0,G.jsx)(gv,{fontSize:`small`}):(0,G.jsx)(Ob,{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 z6e=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`})]})}),B6e=e=>{let t=m6e();return(0,G.jsxs)(Z,{component:da,to:Y9.dashboard,sx:{display:`flex`,alignItems:`center`,justifyContent:e.large?`flex-start`:`center`,flexGrow:1,textDecoration:`none`,color:`inherit`},children:[(0,G.jsx)(z6e,{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})]})},V6e=()=>{let e=F6e(`(min-width:600px)`),{mode:t,setMode:n}=Pm(),[r,i]=(0,C.useState)(!1),[a,o]=(0,C.useState)(!1),s=Pr(),c=jr(),l=e=>e?e===`/`?c.pathname===`/`:c.pathname.startsWith(e):!1,u=()=>{n(t===`dark`?`light`:`dark`)},{t:d}=Ts(),f=[{label:d(`dashboard.title`),icon:(0,G.jsx)(iE,{}),to:Y9.dashboard},{label:d(`nav.bridges`),icon:(0,G.jsx)(aE,{}),to:Y9.bridges},{label:d(`nav.devices`),icon:(0,G.jsx)(xb,{}),to:Y9.devices},{label:d(`nav.standaloneDevices`,`Standalone Devices`),icon:(0,G.jsx)(cge,{}),to:Y9.standaloneDevices},{label:d(`nav.networkMap`),icon:(0,G.jsx)(WT,{}),to:Y9.networkMap},{label:d(`nav.startupOrder`),icon:(0,G.jsx)(_v,{}),to:Y9.startup},{label:d(`nav.lockCredentials`),icon:(0,G.jsx)(CT,{}),to:Y9.lockCredentials},{label:d(`nav.filterReference`),icon:(0,G.jsx)(oE,{}),to:Y9.labels},{label:`Plugins`,icon:(0,G.jsx)(nE,{}),to:Y9.plugins},{label:d(`nav.settings`),icon:(0,G.jsx)(MT,{}),to:Y9.settings},{label:d(t===`dark`?`nav.lightMode`:`nav.darkMode`),icon:t===`dark`?(0,G.jsx)(tge,{}):(0,G.jsx)(Hhe,{}),onClick:u},{label:d(`nav.systemLogs`),icon:(0,G.jsx)(XT,{}),onClick:()=>i(!0)},{label:d(`nav.health`),icon:(0,G.jsx)(Mx,{}),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)(b6e,{sx:{height:`72px`},children:(0,G.jsx)(t6e,{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)(B6e,{large:e}),e?(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[f.map(e=>e.to?(0,G.jsx)(vb,{title:e.label,children:(0,G.jsx)(Vh,{component:da,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)(vb,{title:e.label,children:(0,G.jsx)(Vh,{onClick:e.onClick,sx:{color:`inherit`},children:e.icon})},e.label)),(0,G.jsx)(R6e,{})]}):(0,G.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,G.jsx)(R6e,{}),(0,G.jsx)(Vh,{onClick:()=>o(!0),sx:{color:`inherit`},children:(0,G.jsx)(nge,{})})]})]})})}),(0,G.jsx)(P6e,{anchor:`right`,open:a,onClose:()=>o(!1),children:(0,G.jsx)(oy,{sx:{width:250},children:f.map(e=>(0,G.jsxs)(Gae,{selected:l(e.to),onClick:()=>p(e),children:[(0,G.jsx)(dy,{children:e.icon}),(0,G.jsx)(py,{primary:e.label})]},e.label))})}),(0,G.jsx)(L6e,{open:r,onClose:()=>i(!1)})]})},H6e=()=>{let{versionMismatch:e,frontendVersion:t,backendVersion:n}=m6e(),{isConnected:r}=iv();return(0,G.jsxs)(Z,{children:[(0,G.jsx)(V6e,{}),(0,G.jsx)(t6e,{}),e&&(0,G.jsxs)(Wh,{severity:`warning`,variant:`filled`,sx:{borderRadius:0},action:(0,G.jsx)(xv,{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)(Wh,{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)(n6e,{children:(0,G.jsx)(vi,{})})}),(0,G.jsx)(h6e,{}),(0,G.jsx)(f6e,{})]})},U6e=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 W6e=sa([{path:`/`,element:(0,G.jsx)(H6e,{}),children:J3e}],{basename:$9});(0,S.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(C.StrictMode,{children:(0,G.jsx)(L,{store:Z3e,children:(0,G.jsxs)(ite,{theme:U6e,children:[(0,G.jsx)(Qee,{}),(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)(Ore,{children:(0,G.jsx)(bne,{children:(0,G.jsx)(ja,{router:W6e})})})]})})}));