@flow-as-code/studio 0.1.0

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.
@@ -0,0 +1,23 @@
1
+ import{i as e,o as t,t as n}from"./rolldown-runtime-C0FnF6B9.js";import{i as r,n as i,t as a}from"./react-CoFFvonC.js";import{a as o,c as s,i as c,l,n as u,o as d,r as f,s as p,t as m}from"./reactflow-CPLqUIKy.js";import{t as h}from"./ajv-BkL7o0uA.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var g=t(r(),1),_=i(),v=[`%`,`:`,`(`,`\\`,`/`,`)`,`=`,`$`,`,`,`;`,`[`,`]`,`{`,`}`],y=[`__proto__`,`constructor`,`__defineGetter__`,`__defineSetter__`,`toString`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`valueOf`],b=/^[a-z0-9]+(-[a-z0-9]+)*$/;function x(e){return e.length===0||e.length>50||y.includes(e)?!1:!v.some(t=>e.includes(t))}var S=class extends Error{constructor(e){super(e),this.name=`InvalidFlowDocError`}};function C(e){return e===null?`null`:e===void 0?`undefined`:Array.isArray(e)?`an array`:typeof e==`string`?`a string (${JSON.stringify(e)})`:`a ${typeof e}`}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e,t){if(!w(e))throw new S(`${t} expects a FlowDoc object, got ${C(e)}.`);for(let n of[`name`,`kind`,`connectType`])if(typeof e[n]!=`string`)throw new S(`${t} expects a FlowDoc with a string "${n}", got ${C(e[n])}.`);let n=e.content;if(!w(n))throw new S(`${t} expects a FlowDoc with an object "content", got ${C(n)}.`);if(typeof n.StartAction!=`string`)throw new S(`${t} expects a FlowDoc with a string "content.StartAction", got ${C(n.StartAction)}.`);let r=n.Actions;if(!Array.isArray(r))throw new S(`${t} expects a FlowDoc with an array "content.Actions", got ${C(r)}.`);for(let[e,n]of r.entries()){let r=`${t}: FlowDoc content.Actions[${String(e)}]`;if(!w(n))throw new S(`${r} must be an action object, got ${C(n)}.`);for(let e of[`Identifier`,`Type`])if(typeof n[e]!=`string`)throw new S(`${r} must have a string "${e}", got ${C(n[e])}.`);for(let e of[`Parameters`,`Transitions`])if(!w(n[e]))throw new S(`${r} ("${String(n.Identifier)}") must have an object "${e}", got ${C(n[e])}.`)}}var E=/^\$\{cdref:(queue|hours|lambda|lex|prompt|flow|module):([a-z0-9]+(?:-[a-z0-9]+)*)(?:@([a-z0-9]+(?:-[a-z0-9]+)*))?\}$/,D=/\$\{cdref:[a-z]+:[^}]+\}/g;function O(e){let t=E.exec(e);if(!t)return;let[,n,r,i]=t,a={token:e,type:n,name:r};return i!==void 0&&(a.alias=i),a}function k(e){let t=new Map;for(let n of JSON.stringify(e??null).match(D)??[]){let e=O(n);e&&t.set(e.token,e)}return[...t.values()].sort((e,t)=>e.token<t.token?-1:+(e.token>t.token))}var A={MessageParticipant:`MessageParticipant`,GetParticipantInput:`GetParticipantInput`,DisconnectParticipant:`DisconnectParticipant`,CheckHoursOfOperation:`CheckHoursOfOperation`,Compare:`Compare`,TransferToFlow:`TransferToFlow`,EndFlowExecution:`EndFlowExecution`,TransferContactToQueue:`TransferContactToQueue`,UpdateContactTargetQueue:`UpdateContactTargetQueue`,UpdateContactAttributes:`UpdateContactAttributes`,UpdateContactRecordingBehavior:`UpdateContactRecordingBehavior`,InvokeFlowModule:`InvokeFlowModule`,EndFlowModuleExecution:`EndFlowModuleExecution`,InvokeLambdaFunction:`InvokeLambdaFunction`},j={[A.UpdateContactTargetQueue]:{QueueId:`queue`,AgentId:`queue`},[A.CheckHoursOfOperation]:{HoursOfOperationId:`hours`},[A.InvokeLambdaFunction]:{LambdaFunctionARN:`lambda`},[A.InvokeFlowModule]:{FlowModuleId:`module`},[A.TransferToFlow]:{ContactFlowId:`flow`},[A.MessageParticipant]:{PromptId:`prompt`},[A.GetParticipantInput]:{PromptId:`prompt`}},ee=[A.DisconnectParticipant,A.EndFlowExecution,A.EndFlowModuleExecution],M=`NoMatchingError`,N=`NoMatchingCondition`,te=`InputTimeLimitExceeded`,ne={[A.TransferContactToQueue]:[`QueueAtCapacity`],[A.GetParticipantInput]:[te,N]},P=[`CONTACT_FLOW`],F=[`AGENT_TRANSFER`,`QUEUE_TRANSFER`],re=[`CUSTOMER_WHISPER`,`AGENT_WHISPER`,`OUTBOUND_WHISPER`],I=[`CUSTOMER_QUEUE`],L=[`MODULE`],ie={[A.MessageParticipant]:[...P,...F,...re,...I,...L],[A.GetParticipantInput]:[...P,...F,...I,...L],[A.DisconnectParticipant]:[...P,...F,...I,...L],[A.CheckHoursOfOperation]:[...P,...F,...I,...L],[A.EndFlowExecution]:[...re,...I,...L],[A.EndFlowModuleExecution]:[...L],[A.InvokeFlowModule]:[...P,...L],[A.TransferContactToQueue]:[...P,...F,...L],[A.UpdateContactTargetQueue]:[...P,...F,...L],[A.TransferToFlow]:[...P,...F,...L],[A.UpdateContactRecordingBehavior]:[...P,...F,`OUTBOUND_WHISPER`,...I,...L]};A.Compare,A.UpdateContactAttributes,A.InvokeLambdaFunction;var ae=[`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`*`,`#`];function oe(e){return typeof e==`string`?e:e.id}var R=class{id;constructor(e){if(!x(e))throw Error(`Invalid Identifier "${e}". Must be 1 to 50 characters and must not contain % : ( \\ / ) = $ , ; [ ] { }.`);this.id=e}toAction(){return{Identifier:this.id,Type:this.type,Parameters:this.parameters(),Transitions:this.transitions()}}};function z(e,t,n=[]){let r={};return e!==void 0&&(r.NextAction=oe(e)),r.Errors=t.map(([e,t])=>({ErrorType:e,NextAction:oe(t)})),r.Conditions=n.map(e=>({NextAction:oe(e.target),Condition:{Operator:e.operator,Operands:e.operands}})),r}var se=class extends R{config;type=A.MessageParticipant;constructor(e){super(e.id),this.config=e}parameters(){let{text:e,ssml:t,prompt:n}=this.config;return e===void 0?t===void 0?{PromptId:n}:{SSML:t}:{Text:e}}transitions(){return z(this.config.next,[[M,this.config.onError]])}},ce=class extends R{config;type=A.GetParticipantInput;constructor(e){super(e.id),this.config=e;let t=e.timeoutSeconds;if(!Number.isInteger(t)||t<1||t>180)throw Error(`GetParticipantInput "${e.id}" timeoutSeconds must be an integer between 1 and 180, got ${t}.`);let n=new Set;for(let t of e.branches){if(!ae.includes(t.digit))throw Error(`GetParticipantInput "${e.id}" branch digit must be one of ${ae.join(` `)}, got "${String(t.digit)}".`);if(n.has(t.digit))throw Error(`GetParticipantInput "${e.id}" branches on key "${t.digit}" twice; each key may branch once.`);n.add(t.digit)}}parameters(){let{text:e,ssml:t,prompt:n}=this.config,r={};return e===void 0?t===void 0?n!==void 0&&(r.PromptId=n):r.SSML=t:r.Text=e,r.InputTimeLimitSeconds=String(this.config.timeoutSeconds),r.StoreInput=`False`,r}transitions(){let{onTimeout:e,onNoMatch:t,onError:n}=this.config;return z(t,[[te,e],[N,t],[M,n]],this.config.branches.map(e=>({target:e.target,operator:`Equals`,operands:[e.digit]})))}},le=class extends R{type=A.DisconnectParticipant;constructor(e){super(e.id)}parameters(){return{}}transitions(){return{}}},ue=class extends R{config;type=A.CheckHoursOfOperation;constructor(e){super(e.id),this.config=e}parameters(){return this.config.hours===void 0?{}:{HoursOfOperationId:this.config.hours}}transitions(){return z(this.config.onOutOfHours,[[M,this.config.onError]],[{target:this.config.onInHours,operator:`Equals`,operands:[`True`]},{target:this.config.onOutOfHours,operator:`Equals`,operands:[`False`]}])}},de=class extends R{config;type=A.Compare;constructor(e){if(super(e.id),this.config=e,e.branches.length===0)throw Error(`Compare "${e.id}" needs at least one branch.`)}parameters(){return{ComparisonValue:this.config.value}}transitions(){return z(void 0,[[N,this.config.onNoMatch]],this.config.branches.map(e=>({target:e.target,operator:e.operator,operands:e.operands})))}},fe=class extends R{config;type=A.TransferToFlow;constructor(e){super(e.id),this.config=e}parameters(){return{ContactFlowId:this.config.flow}}transitions(){return z(this.config.next,[[M,this.config.onError]])}},B=class extends R{type=A.EndFlowExecution;constructor(e){super(e.id)}parameters(){return{}}transitions(){return{}}},pe=class extends R{config;type=A.UpdateContactTargetQueue;constructor(e){super(e.id),this.config=e}parameters(){return this.config.queue===void 0?{AgentId:this.config.agent}:{QueueId:this.config.queue}}transitions(){return z(this.config.next,[[M,this.config.onError]])}},me=class extends R{config;type=A.TransferContactToQueue;constructor(e){super(e.id),this.config=e}parameters(){return{}}transitions(){let e=(ne[A.TransferContactToQueue]??[]).map(e=>[e,this.config.onQueueAtCapacity]);return e.push([M,this.config.onError]),z(this.config.next,e)}},he=class extends R{config;type=A.UpdateContactAttributes;constructor(e){super(e.id),this.config=e}parameters(){return{Attributes:this.config.attributes,TargetContact:this.config.targetContact??`Current`}}transitions(){return z(this.config.next,[[M,this.config.onError]])}},ge=class extends R{config;type=A.UpdateContactRecordingBehavior;constructor(e){super(e.id),this.config=e}parameters(){let e={RecordedParticipants:this.config.recordedParticipants};return this.config.screenRecordedParticipants!==void 0&&(e.ScreenRecordedParticipants=this.config.screenRecordedParticipants),this.config.ivrRecordingBehavior!==void 0&&(e.IVRRecordingBehavior=this.config.ivrRecordingBehavior),{RecordingBehavior:e}}transitions(){return z(this.config.next,[[M,this.config.onError]])}},_e=class extends R{config;type=A.InvokeFlowModule;constructor(e){super(e.id),this.config=e}parameters(){return{FlowModuleId:this.config.module}}transitions(){return z(this.config.next,[[M,this.config.onError]])}},ve=class extends R{type=A.EndFlowModuleExecution;constructor(e){super(e.id)}parameters(){return{}}transitions(){return{}}},ye=class extends R{config;type=A.InvokeLambdaFunction;constructor(e){super(e.id),this.config=e;let t=e.timeoutSeconds;if(!Number.isInteger(t)||t<1||t>8)throw Error(`InvokeLambdaFunction "${e.id}" timeoutSeconds must be an integer between 1 and 8, got ${t}.`)}parameters(){let e={LambdaFunctionARN:this.config.lambda,InvocationTimeLimitSeconds:this.config.timeoutSeconds,InvocationType:this.config.invocationType??`SYNCHRONOUS`};return this.config.attributes!==void 0&&(e.LambdaInvocationAttributes=this.config.attributes),this.config.responseType!==void 0&&(e.ResponseValidation={ResponseType:this.config.responseType}),e}transitions(){return z(this.config.next,[[M,this.config.onError]])}},be=class extends R{config;type;constructor(e){super(e.id),this.config=e,this.type=e.type}parameters(){return this.config.parameters??{}}transitions(){return this.config.next===void 0&&(this.config.errors??[]).length===0&&(this.config.conditions??[]).length===0?{}:z(this.config.next,(this.config.errors??[]).map(e=>[e.errorType,e.target]),this.config.conditions??[])}},xe=n(((e,t)=>{function n(){this.__data__=[],this.size=0}t.exports=n})),Se=n(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Ce=n(((e,t)=>{var n=Se();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),we=n(((e,t)=>{var n=Ce(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Te=n(((e,t)=>{var n=Ce();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Ee=n(((e,t)=>{var n=Ce();function r(e){return n(this.__data__,e)>-1}t.exports=r})),De=n(((e,t)=>{var n=Ce();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),Oe=n(((e,t)=>{var n=xe(),r=we(),i=Te(),a=Ee(),o=De();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),ke=n(((e,t)=>{var n=Oe();function r(){this.__data__=new n,this.size=0}t.exports=r})),Ae=n(((e,t)=>{function n(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}t.exports=n})),je=n(((e,t)=>{function n(e){return this.__data__.get(e)}t.exports=n})),Me=n(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),Ne=n(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),Pe=n(((e,t)=>{var n=Ne(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),Fe=n(((e,t)=>{t.exports=Pe().Symbol})),Ie=n(((e,t)=>{var n=Fe(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),Le=n(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),Re=n(((e,t)=>{var n=Fe(),r=Ie(),i=Le(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),V=n(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),ze=n(((e,t)=>{var n=Re(),r=V(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),Be=n(((e,t)=>{t.exports=Pe()[`__core-js_shared__`]})),Ve=n(((e,t)=>{var n=Be(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),He=n(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),Ue=n(((e,t)=>{var n=ze(),r=Ve(),i=V(),a=He(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),We=n(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),Ge=n(((e,t)=>{var n=Ue(),r=We();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),Ke=n(((e,t)=>{t.exports=Ge()(Pe(),`Map`)})),qe=n(((e,t)=>{t.exports=Ge()(Object,`create`)})),Je=n(((e,t)=>{var n=qe();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),Ye=n(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),Xe=n(((e,t)=>{var n=qe(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),Ze=n(((e,t)=>{var n=qe(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),Qe=n(((e,t)=>{var n=qe(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),$e=n(((e,t)=>{var n=Je(),r=Ye(),i=Xe(),a=Ze(),o=Qe();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),et=n(((e,t)=>{var n=$e(),r=Oe(),i=Ke();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),tt=n(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),nt=n(((e,t)=>{var n=tt();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),rt=n(((e,t)=>{var n=nt();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),it=n(((e,t)=>{var n=nt();function r(e){return n(this,e).get(e)}t.exports=r})),at=n(((e,t)=>{var n=nt();function r(e){return n(this,e).has(e)}t.exports=r})),ot=n(((e,t)=>{var n=nt();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),st=n(((e,t)=>{var n=et(),r=rt(),i=it(),a=at(),o=ot();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=n,s.prototype.delete=r,s.prototype.get=i,s.prototype.has=a,s.prototype.set=o,t.exports=s})),ct=n(((e,t)=>{var n=Oe(),r=Ke(),i=st(),a=200;function o(e,t){var o=this.__data__;if(o instanceof n){var s=o.__data__;if(!r||s.length<a-1)return s.push([e,t]),this.size=++o.size,this;o=this.__data__=new i(s)}return o.set(e,t),this.size=o.size,this}t.exports=o})),lt=n(((e,t)=>{var n=Oe(),r=ke(),i=Ae(),a=je(),o=Me(),s=ct();function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c})),ut=n(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}t.exports=n})),dt=n(((e,t)=>{var n=Ge();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),ft=n(((e,t)=>{var n=dt();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),pt=n(((e,t)=>{var n=ft(),r=Se(),i=Object.prototype.hasOwnProperty;function a(e,t,a){var o=e[t];(!(i.call(e,t)&&r(o,a))||a===void 0&&!(t in e))&&n(e,t,a)}t.exports=a})),mt=n(((e,t)=>{var n=pt(),r=ft();function i(e,t,i,a){var o=!i;i||={};for(var s=-1,c=t.length;++s<c;){var l=t[s],u=a?a(i[l],e[l],l,i,e):void 0;u===void 0&&(u=e[l]),o?r(i,l,u):n(i,l,u)}return i}t.exports=i})),ht=n(((e,t)=>{function n(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}t.exports=n})),gt=n(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),_t=n(((e,t)=>{var n=Re(),r=gt(),i=`[object Arguments]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),vt=n(((e,t)=>{var n=_t(),r=gt(),i=Object.prototype,a=i.hasOwnProperty,o=i.propertyIsEnumerable;t.exports=n(function(){return arguments}())?n:function(e){return r(e)&&a.call(e,`callee`)&&!o.call(e,`callee`)}})),H=n(((e,t)=>{t.exports=Array.isArray})),yt=n(((e,t)=>{function n(){return!1}t.exports=n})),bt=n(((e,t)=>{var n=Pe(),r=yt(),i=typeof e==`object`&&e&&!e.nodeType&&e,a=i&&typeof t==`object`&&t&&!t.nodeType&&t,o=a&&a.exports===i?n.Buffer:void 0;t.exports=(o?o.isBuffer:void 0)||r})),xt=n(((e,t)=>{var n=/^(?:0|[1-9]\d*)$/;function r(e,t){var r=typeof e;return t??=9007199254740991,!!t&&(r==`number`||r!=`symbol`&&n.test(e))&&e>-1&&e%1==0&&e<t}t.exports=r})),St=n(((e,t)=>{function n(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991}t.exports=n})),Ct=n(((e,t)=>{var n=Re(),r=St(),i=gt(),a=`[object Arguments]`,o=`[object Array]`,s=`[object Boolean]`,c=`[object Date]`,l=`[object Error]`,u=`[object Function]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object WeakMap]`,v=`[object ArrayBuffer]`,y=`[object DataView]`,b=`[object Float32Array]`,x=`[object Float64Array]`,S=`[object Int8Array]`,C=`[object Int16Array]`,w=`[object Int32Array]`,T=`[object Uint8Array]`,E=`[object Uint8ClampedArray]`,D=`[object Uint16Array]`,O=`[object Uint32Array]`,k={};k[b]=k[x]=k[S]=k[C]=k[w]=k[T]=k[E]=k[D]=k[O]=!0,k[a]=k[o]=k[v]=k[s]=k[y]=k[c]=k[l]=k[u]=k[d]=k[f]=k[p]=k[m]=k[h]=k[g]=k[_]=!1;function A(e){return i(e)&&r(e.length)&&!!k[n(e)]}t.exports=A})),wt=n(((e,t)=>{function n(e){return function(t){return e(t)}}t.exports=n})),Tt=n(((e,t)=>{var n=Ne(),r=typeof e==`object`&&e&&!e.nodeType&&e,i=r&&typeof t==`object`&&t&&!t.nodeType&&t,a=i&&i.exports===r&&n.process;t.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})),Et=n(((e,t)=>{var n=Ct(),r=wt(),i=Tt(),a=i&&i.isTypedArray;t.exports=a?r(a):n})),Dt=n(((e,t)=>{var n=ht(),r=vt(),i=H(),a=bt(),o=xt(),s=Et(),c=Object.prototype.hasOwnProperty;function l(e,t){var l=i(e),u=!l&&r(e),d=!l&&!u&&a(e),f=!l&&!u&&!d&&s(e),p=l||u||d||f,m=p?n(e.length,String):[],h=m.length;for(var g in e)(t||c.call(e,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||o(g,h)))&&m.push(g);return m}t.exports=l})),Ot=n(((e,t)=>{var n=Object.prototype;function r(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||n)}t.exports=r})),kt=n(((e,t)=>{function n(e,t){return function(n){return e(t(n))}}t.exports=n})),At=n(((e,t)=>{t.exports=kt()(Object.keys,Object)})),jt=n(((e,t)=>{var n=Ot(),r=At(),i=Object.prototype.hasOwnProperty;function a(e){if(!n(e))return r(e);var t=[];for(var a in Object(e))i.call(e,a)&&a!=`constructor`&&t.push(a);return t}t.exports=a})),Mt=n(((e,t)=>{var n=ze(),r=St();function i(e){return e!=null&&r(e.length)&&!n(e)}t.exports=i})),Nt=n(((e,t)=>{var n=Dt(),r=jt(),i=Mt();function a(e){return i(e)?n(e):r(e)}t.exports=a})),Pt=n(((e,t)=>{var n=mt(),r=Nt();function i(e,t){return e&&n(t,r(t),e)}t.exports=i})),Ft=n(((e,t)=>{function n(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}t.exports=n})),It=n(((e,t)=>{var n=V(),r=Ot(),i=Ft(),a=Object.prototype.hasOwnProperty;function o(e){if(!n(e))return i(e);var t=r(e),o=[];for(var s in e)s==`constructor`&&(t||!a.call(e,s))||o.push(s);return o}t.exports=o})),Lt=n(((e,t)=>{var n=Dt(),r=It(),i=Mt();function a(e){return i(e)?n(e,!0):r(e)}t.exports=a})),Rt=n(((e,t)=>{var n=mt(),r=Lt();function i(e,t){return e&&n(t,r(t),e)}t.exports=i})),zt=n(((e,t)=>{var n=Pe(),r=typeof e==`object`&&e&&!e.nodeType&&e,i=r&&typeof t==`object`&&t&&!t.nodeType&&t,a=i&&i.exports===r?n.Buffer:void 0,o=a?a.allocUnsafe:void 0;function s(e,t){if(t)return e.slice();var n=e.length,r=o?o(n):new e.constructor(n);return e.copy(r),r}t.exports=s})),Bt=n(((e,t)=>{function n(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}t.exports=n})),Vt=n(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}t.exports=n})),Ht=n(((e,t)=>{function n(){return[]}t.exports=n})),Ut=n(((e,t)=>{var n=Vt(),r=Ht(),i=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;t.exports=a?function(e){return e==null?[]:(e=Object(e),n(a(e),function(t){return i.call(e,t)}))}:r})),Wt=n(((e,t)=>{var n=mt(),r=Ut();function i(e,t){return n(e,r(e),t)}t.exports=i})),Gt=n(((e,t)=>{function n(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}t.exports=n})),Kt=n(((e,t)=>{t.exports=kt()(Object.getPrototypeOf,Object)})),qt=n(((e,t)=>{var n=Gt(),r=Kt(),i=Ut(),a=Ht();t.exports=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)n(t,i(e)),e=r(e);return t}:a})),Jt=n(((e,t)=>{var n=mt(),r=qt();function i(e,t){return n(e,r(e),t)}t.exports=i})),Yt=n(((e,t)=>{var n=Gt(),r=H();function i(e,t,i){var a=t(e);return r(e)?a:n(a,i(e))}t.exports=i})),Xt=n(((e,t)=>{var n=Yt(),r=Ut(),i=Nt();function a(e){return n(e,i,r)}t.exports=a})),Zt=n(((e,t)=>{var n=Yt(),r=qt(),i=Lt();function a(e){return n(e,i,r)}t.exports=a})),Qt=n(((e,t)=>{t.exports=Ge()(Pe(),`DataView`)})),$t=n(((e,t)=>{t.exports=Ge()(Pe(),`Promise`)})),en=n(((e,t)=>{t.exports=Ge()(Pe(),`Set`)})),tn=n(((e,t)=>{t.exports=Ge()(Pe(),`WeakMap`)})),nn=n(((e,t)=>{var n=Qt(),r=Ke(),i=$t(),a=en(),o=tn(),s=Re(),c=He(),l=`[object Map]`,u=`[object Object]`,d=`[object Promise]`,f=`[object Set]`,p=`[object WeakMap]`,m=`[object DataView]`,h=c(n),g=c(r),_=c(i),v=c(a),y=c(o),b=s;(n&&b(new n(new ArrayBuffer(1)))!=m||r&&b(new r)!=l||i&&b(i.resolve())!=d||a&&b(new a)!=f||o&&b(new o)!=p)&&(b=function(e){var t=s(e),n=t==u?e.constructor:void 0,r=n?c(n):``;if(r)switch(r){case h:return m;case g:return l;case _:return d;case v:return f;case y:return p}return t}),t.exports=b})),rn=n(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]==`string`&&n.call(e,`index`)&&(r.index=e.index,r.input=e.input),r}t.exports=r})),an=n(((e,t)=>{t.exports=Pe().Uint8Array})),on=n(((e,t)=>{var n=an();function r(e){var t=new e.constructor(e.byteLength);return new n(t).set(new n(e)),t}t.exports=r})),sn=n(((e,t)=>{var n=on();function r(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}t.exports=r})),cn=n(((e,t)=>{var n=/\w*$/;function r(e){var t=new e.constructor(e.source,n.exec(e));return t.lastIndex=e.lastIndex,t}t.exports=r})),ln=n(((e,t)=>{var n=Fe(),r=n?n.prototype:void 0,i=r?r.valueOf:void 0;function a(e){return i?Object(i.call(e)):{}}t.exports=a})),un=n(((e,t)=>{var n=on();function r(e,t){var r=t?n(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}t.exports=r})),dn=n(((e,t)=>{var n=on(),r=sn(),i=cn(),a=ln(),o=un(),s=`[object Boolean]`,c=`[object Date]`,l=`[object Map]`,u=`[object Number]`,d=`[object RegExp]`,f=`[object Set]`,p=`[object String]`,m=`[object Symbol]`,h=`[object ArrayBuffer]`,g=`[object DataView]`,_=`[object Float32Array]`,v=`[object Float64Array]`,y=`[object Int8Array]`,b=`[object Int16Array]`,x=`[object Int32Array]`,S=`[object Uint8Array]`,C=`[object Uint8ClampedArray]`,w=`[object Uint16Array]`,T=`[object Uint32Array]`;function E(e,t,E){var D=e.constructor;switch(t){case h:return n(e);case s:case c:return new D(+e);case g:return r(e,E);case _:case v:case y:case b:case x:case S:case C:case w:case T:return o(e,E);case l:return new D;case u:case p:return new D(e);case d:return i(e);case f:return new D;case m:return a(e)}}t.exports=E})),fn=n(((e,t)=>{var n=V(),r=Object.create;t.exports=function(){function e(){}return function(t){if(!n(t))return{};if(r)return r(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}()})),pn=n(((e,t)=>{var n=fn(),r=Kt(),i=Ot();function a(e){return typeof e.constructor==`function`&&!i(e)?n(r(e)):{}}t.exports=a})),mn=n(((e,t)=>{var n=nn(),r=gt(),i=`[object Map]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),hn=n(((e,t)=>{var n=mn(),r=wt(),i=Tt(),a=i&&i.isMap;t.exports=a?r(a):n})),gn=n(((e,t)=>{var n=nn(),r=gt(),i=`[object Set]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),_n=n(((e,t)=>{var n=gn(),r=wt(),i=Tt(),a=i&&i.isSet;t.exports=a?r(a):n})),vn=n(((e,t)=>{var n=lt(),r=ut(),i=pt(),a=Pt(),o=Rt(),s=zt(),c=Bt(),l=Wt(),u=Jt(),d=Xt(),f=Zt(),p=nn(),m=rn(),h=dn(),g=pn(),_=H(),v=bt(),y=hn(),b=V(),x=_n(),S=Nt(),C=Lt(),w=1,T=2,E=4,D=`[object Arguments]`,O=`[object Array]`,k=`[object Boolean]`,A=`[object Date]`,j=`[object Error]`,ee=`[object Function]`,M=`[object GeneratorFunction]`,N=`[object Map]`,te=`[object Number]`,ne=`[object Object]`,P=`[object RegExp]`,F=`[object Set]`,re=`[object String]`,I=`[object Symbol]`,L=`[object WeakMap]`,ie=`[object ArrayBuffer]`,ae=`[object DataView]`,oe=`[object Float32Array]`,R=`[object Float64Array]`,z=`[object Int8Array]`,se=`[object Int16Array]`,ce=`[object Int32Array]`,le=`[object Uint8Array]`,ue=`[object Uint8ClampedArray]`,de=`[object Uint16Array]`,fe=`[object Uint32Array]`,B={};B[D]=B[O]=B[ie]=B[ae]=B[k]=B[A]=B[oe]=B[R]=B[z]=B[se]=B[ce]=B[N]=B[te]=B[ne]=B[P]=B[F]=B[re]=B[I]=B[le]=B[ue]=B[de]=B[fe]=!0,B[j]=B[ee]=B[L]=!1;function pe(e,t,O,k,A,j){var N,te=t&w,P=t&T,F=t&E;if(O&&(N=A?O(e,k,A,j):O(e)),N!==void 0)return N;if(!b(e))return e;var re=_(e);if(re){if(N=m(e),!te)return c(e,N)}else{var I=p(e),L=I==ee||I==M;if(v(e))return s(e,te);if(I==ne||I==D||L&&!A){if(N=P||L?{}:g(e),!te)return P?u(e,o(N,e)):l(e,a(N,e))}else{if(!B[I])return A?e:{};N=h(e,I,te)}}j||=new n;var ie=j.get(e);if(ie)return ie;j.set(e,N),x(e)?e.forEach(function(n){N.add(pe(n,t,O,n,e,j))}):y(e)&&e.forEach(function(n,r){N.set(r,pe(n,t,O,r,e,j))});var ae=re?void 0:(F?P?f:d:P?C:S)(e);return r(ae||e,function(n,r){ae&&(r=n,n=e[r]),i(N,r,pe(n,t,O,r,e,j))}),N}t.exports=pe})),yn=n(((e,t)=>{var n=vn(),r=4;function i(e){return n(e,r)}t.exports=i})),bn=n(((e,t)=>{function n(e){return function(){return e}}t.exports=n})),xn=n(((e,t)=>{function n(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}t.exports=n})),Sn=n(((e,t)=>{t.exports=xn()()})),Cn=n(((e,t)=>{var n=Sn(),r=Nt();function i(e,t){return e&&n(e,t,r)}t.exports=i})),wn=n(((e,t)=>{var n=Mt();function r(e,t){return function(r,i){if(r==null)return r;if(!n(r))return e(r,i);for(var a=r.length,o=t?a:-1,s=Object(r);(t?o--:++o<a)&&i(s[o],o,s)!==!1;);return r}}t.exports=r})),Tn=n(((e,t)=>{var n=Cn();t.exports=wn()(n)})),En=n(((e,t)=>{function n(e){return e}t.exports=n})),Dn=n(((e,t)=>{var n=En();function r(e){return typeof e==`function`?e:n}t.exports=r})),On=n(((e,t)=>{var n=ut(),r=Tn(),i=Dn(),a=H();function o(e,t){return(a(e)?n:r)(e,i(t))}t.exports=o})),kn=n(((e,t)=>{t.exports=On()})),An=n(((e,t)=>{var n=Tn();function r(e,t){var r=[];return n(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r}t.exports=r})),jn=n(((e,t)=>{function n(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this}t.exports=n})),Mn=n(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),Nn=n(((e,t)=>{var n=st(),r=jn(),i=Mn();function a(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new n;++t<r;)this.add(e[t])}a.prototype.add=a.prototype.push=r,a.prototype.has=i,t.exports=a})),Pn=n(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}t.exports=n})),Fn=n(((e,t)=>{function n(e,t){return e.has(t)}t.exports=n})),In=n(((e,t)=>{var n=Nn(),r=Pn(),i=Fn(),a=1,o=2;function s(e,t,s,c,l,u){var d=s&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(e),h=u.get(t);if(m&&h)return m==t&&h==e;var g=-1,_=!0,v=s&o?new n:void 0;for(u.set(e,t),u.set(t,e);++g<f;){var y=e[g],b=t[g];if(c)var x=d?c(b,y,g,t,e,u):c(y,b,g,e,t,u);if(x!==void 0){if(x)continue;_=!1;break}if(v){if(!r(t,function(e,t){if(!i(v,t)&&(y===e||l(y,e,s,c,u)))return v.push(t)})){_=!1;break}}else if(!(y===b||l(y,b,s,c,u))){_=!1;break}}return u.delete(e),u.delete(t),_}t.exports=s})),Ln=n(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}t.exports=n})),Rn=n(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}t.exports=n})),zn=n(((e,t)=>{var n=Fe(),r=an(),i=Se(),a=In(),o=Ln(),s=Rn(),c=1,l=2,u=`[object Boolean]`,d=`[object Date]`,f=`[object Error]`,p=`[object Map]`,m=`[object Number]`,h=`[object RegExp]`,g=`[object Set]`,_=`[object String]`,v=`[object Symbol]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=n?n.prototype:void 0,S=x?x.valueOf:void 0;function C(e,t,n,x,C,w,T){switch(n){case b:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case y:return!(e.byteLength!=t.byteLength||!w(new r(e),new r(t)));case u:case d:case m:return i(+e,+t);case f:return e.name==t.name&&e.message==t.message;case h:case _:return e==t+``;case p:var E=o;case g:var D=x&c;if(E||=s,e.size!=t.size&&!D)return!1;var O=T.get(e);if(O)return O==t;x|=l,T.set(e,t);var k=a(E(e),E(t),x,C,w,T);return T.delete(e),k;case v:if(S)return S.call(e)==S.call(t)}return!1}t.exports=C})),Bn=n(((e,t)=>{var n=Xt(),r=1,i=Object.prototype.hasOwnProperty;function a(e,t,a,o,s,c){var l=a&r,u=n(e),d=u.length;if(d!=n(t).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in t:i.call(t,p)))return!1}var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=!0;c.set(e,t),c.set(t,e);for(var _=l;++f<d;){p=u[f];var v=e[p],y=t[p];if(o)var b=l?o(y,v,p,t,e,c):o(v,y,p,e,t,c);if(!(b===void 0?v===y||s(v,y,a,o,c):b)){g=!1;break}_||=p==`constructor`}if(g&&!_){var x=e.constructor,S=t.constructor;x!=S&&`constructor`in e&&`constructor`in t&&!(typeof x==`function`&&x instanceof x&&typeof S==`function`&&S instanceof S)&&(g=!1)}return c.delete(e),c.delete(t),g}t.exports=a})),Vn=n(((e,t)=>{var n=lt(),r=In(),i=zn(),a=Bn(),o=nn(),s=H(),c=bt(),l=Et(),u=1,d=`[object Arguments]`,f=`[object Array]`,p=`[object Object]`,m=Object.prototype.hasOwnProperty;function h(e,t,h,g,_,v){var y=s(e),b=s(t),x=y?f:o(e),S=b?f:o(t);x=x==d?p:x,S=S==d?p:S;var C=x==p,w=S==p,T=x==S;if(T&&c(e)){if(!c(t))return!1;y=!0,C=!1}if(T&&!C)return v||=new n,y||l(e)?r(e,t,h,g,_,v):i(e,t,x,h,g,_,v);if(!(h&u)){var E=C&&m.call(e,`__wrapped__`),D=w&&m.call(t,`__wrapped__`);if(E||D){var O=E?e.value():e,k=D?t.value():t;return v||=new n,_(O,k,h,g,v)}}return T?(v||=new n,a(e,t,h,g,_,v)):!1}t.exports=h})),Hn=n(((e,t)=>{var n=Vn(),r=gt();function i(e,t,a,o,s){return e===t?!0:e==null||t==null||!r(e)&&!r(t)?e!==e&&t!==t:n(e,t,a,o,i,s)}t.exports=i})),Un=n(((e,t)=>{var n=lt(),r=Hn(),i=1,a=2;function o(e,t,o,s){var c=o.length,l=c,u=!s;if(e==null)return!l;for(e=Object(e);c--;){var d=o[c];if(u&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++c<l;){d=o[c];var f=d[0],p=e[f],m=d[1];if(u&&d[2]){if(p===void 0&&!(f in e))return!1}else{var h=new n;if(s)var g=s(p,m,f,e,t,h);if(!(g===void 0?r(m,p,i|a,s,h):g))return!1}}return!0}t.exports=o})),Wn=n(((e,t)=>{var n=V();function r(e){return e===e&&!n(e)}t.exports=r})),Gn=n(((e,t)=>{var n=Wn(),r=Nt();function i(e){for(var t=r(e),i=t.length;i--;){var a=t[i],o=e[a];t[i]=[a,o,n(o)]}return t}t.exports=i})),Kn=n(((e,t)=>{function n(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}t.exports=n})),qn=n(((e,t)=>{var n=Un(),r=Gn(),i=Kn();function a(e){var t=r(e);return t.length==1&&t[0][2]?i(t[0][0],t[0][1]):function(r){return r===e||n(r,e,t)}}t.exports=a})),Jn=n(((e,t)=>{var n=Re(),r=gt(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),Yn=n(((e,t)=>{var n=H(),r=Jn(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),Xn=n(((e,t)=>{var n=st(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),Zn=n(((e,t)=>{var n=Xn(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),Qn=n(((e,t)=>{var n=Zn(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),$n=n(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}t.exports=n})),er=n(((e,t)=>{var n=Fe(),r=$n(),i=H(),a=Jn(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),tr=n(((e,t)=>{var n=er();function r(e){return e==null?``:n(e)}t.exports=r})),nr=n(((e,t)=>{var n=H(),r=Yn(),i=Qn(),a=tr();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),rr=n(((e,t)=>{var n=Jn(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),ir=n(((e,t)=>{var n=nr(),r=rr();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i<a;)e=e[r(t[i++])];return i&&i==a?e:void 0}t.exports=i})),ar=n(((e,t)=>{var n=ir();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),or=n(((e,t)=>{function n(e,t){return e!=null&&t in Object(e)}t.exports=n})),sr=n(((e,t)=>{var n=nr(),r=vt(),i=H(),a=xt(),o=St(),s=rr();function c(e,t,c){t=n(t,e);for(var l=-1,u=t.length,d=!1;++l<u;){var f=s(t[l]);if(!(d=e!=null&&c(e,f)))break;e=e[f]}return d||++l!=u?d:(u=e==null?0:e.length,!!u&&o(u)&&a(f,u)&&(i(e)||r(e)))}t.exports=c})),cr=n(((e,t)=>{var n=or(),r=sr();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i})),lr=n(((e,t)=>{var n=Hn(),r=ar(),i=cr(),a=Yn(),o=Wn(),s=Kn(),c=rr(),l=1,u=2;function d(e,t){return a(e)&&o(t)?s(c(e),t):function(a){var o=r(a,e);return o===void 0&&o===t?i(a,e):n(t,o,l|u)}}t.exports=d})),ur=n(((e,t)=>{function n(e){return function(t){return t?.[e]}}t.exports=n})),dr=n(((e,t)=>{var n=ir();function r(e){return function(t){return n(t,e)}}t.exports=r})),fr=n(((e,t)=>{var n=ur(),r=dr(),i=Yn(),a=rr();function o(e){return i(e)?n(a(e)):r(e)}t.exports=o})),pr=n(((e,t)=>{var n=qn(),r=lr(),i=En(),a=H(),o=fr();function s(e){return typeof e==`function`?e:e==null?i:typeof e==`object`?a(e)?r(e[0],e[1]):n(e):o(e)}t.exports=s})),mr=n(((e,t)=>{var n=Vt(),r=An(),i=pr(),a=H();function o(e,t){return(a(e)?n:r)(e,i(t,3))}t.exports=o})),hr=n(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e,t){return e!=null&&n.call(e,t)}t.exports=r})),gr=n(((e,t)=>{var n=hr(),r=sr();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i})),_r=n(((e,t)=>{var n=jt(),r=nn(),i=vt(),a=H(),o=Mt(),s=bt(),c=Ot(),l=Et(),u=`[object Map]`,d=`[object Set]`,f=Object.prototype.hasOwnProperty;function p(e){if(e==null)return!0;if(o(e)&&(a(e)||typeof e==`string`||typeof e.splice==`function`||s(e)||l(e)||i(e)))return!e.length;var t=r(e);if(t==u||t==d)return!e.size;if(c(e))return!n(e).length;for(var p in e)if(f.call(e,p))return!1;return!0}t.exports=p})),vr=n(((e,t)=>{function n(e){return e===void 0}t.exports=n})),yr=n(((e,t)=>{var n=Tn(),r=Mt();function i(e,t){var i=-1,a=r(e)?Array(e.length):[];return n(e,function(e,n,r){a[++i]=t(e,n,r)}),a}t.exports=i})),br=n(((e,t)=>{var n=$n(),r=pr(),i=yr(),a=H();function o(e,t){return(a(e)?n:i)(e,r(t,3))}t.exports=o})),xr=n(((e,t)=>{function n(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}t.exports=n})),Sr=n(((e,t)=>{function n(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}t.exports=n})),Cr=n(((e,t)=>{var n=xr(),r=Tn(),i=pr(),a=Sr(),o=H();function s(e,t,s){var c=o(e)?n:a,l=arguments.length<3;return c(e,i(t,4),s,l,r)}t.exports=s})),wr=n(((e,t)=>{var n=Re(),r=H(),i=gt(),a=`[object String]`;function o(e){return typeof e==`string`||!r(e)&&i(e)&&n(e)==a}t.exports=o})),Tr=n(((e,t)=>{t.exports=ur()(`length`)})),Er=n(((e,t)=>{var n=RegExp(`[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]`);function r(e){return n.test(e)}t.exports=r})),Dr=n(((e,t)=>{var n=`\\ud800-\\udfff`,r=`\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff`,i=`\\ufe0e\\ufe0f`,a=`[`+n+`]`,o=`[`+r+`]`,s=`\\ud83c[\\udffb-\\udfff]`,c=`(?:`+o+`|`+s+`)`,l=`[^`+n+`]`,u=`(?:\\ud83c[\\udde6-\\uddff]){2}`,d=`[\\ud800-\\udbff][\\udc00-\\udfff]`,f=`\\u200d`,p=c+`?`,m=`[`+i+`]?`,h=`(?:`+f+`(?:`+[l,u,d].join(`|`)+`)`+m+p+`)*`,g=m+p+h,_=`(?:`+[l+o+`?`,o,u,d,a].join(`|`)+`)`,v=RegExp(s+`(?=`+s+`)|`+_+g,`g`);function y(e){for(var t=v.lastIndex=0;v.test(e);)++t;return t}t.exports=y})),Or=n(((e,t)=>{var n=Tr(),r=Er(),i=Dr();function a(e){return r(e)?i(e):n(e)}t.exports=a})),kr=n(((e,t)=>{var n=jt(),r=nn(),i=Mt(),a=wr(),o=Or(),s=`[object Map]`,c=`[object Set]`;function l(e){if(e==null)return 0;if(i(e))return a(e)?o(e):e.length;var t=r(e);return t==s||t==c?e.size:n(e).length}t.exports=l})),Ar=n(((e,t)=>{var n=ut(),r=fn(),i=Cn(),a=pr(),o=Kt(),s=H(),c=bt(),l=ze(),u=V(),d=Et();function f(e,t,f){var p=s(e),m=p||c(e)||d(e);if(t=a(t,4),f==null){var h=e&&e.constructor;f=m?p?new h:[]:u(e)&&l(h)?r(o(e)):{}}return(m?n:i)(e,function(e,n,r){return t(f,e,n,r)}),f}t.exports=f})),jr=n(((e,t)=>{var n=Fe(),r=vt(),i=H(),a=n?n.isConcatSpreadable:void 0;function o(e){return i(e)||r(e)||!!(a&&e&&e[a])}t.exports=o})),Mr=n(((e,t)=>{var n=Gt(),r=jr();function i(e,t,a,o,s){var c=-1,l=e.length;for(a||=r,s||=[];++c<l;){var u=e[c];t>0&&a(u)?t>1?i(u,t-1,a,o,s):n(s,u):o||(s[s.length]=u)}return s}t.exports=i})),Nr=n(((e,t)=>{function n(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}t.exports=n})),Pr=n(((e,t)=>{var n=Nr(),r=Math.max;function i(e,t,i){return t=r(t===void 0?e.length-1:t,0),function(){for(var a=arguments,o=-1,s=r(a.length-t,0),c=Array(s);++o<s;)c[o]=a[t+o];o=-1;for(var l=Array(t+1);++o<t;)l[o]=a[o];return l[t]=i(c),n(e,this,l)}}t.exports=i})),Fr=n(((e,t)=>{var n=bn(),r=dt(),i=En();t.exports=r?function(e,t){return r(e,`toString`,{configurable:!0,enumerable:!1,value:n(t),writable:!0})}:i})),Ir=n(((e,t)=>{var n=Date.now;function r(e){var t=0,r=0;return function(){var i=n(),a=16-(i-r);if(r=i,a>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}t.exports=r})),Lr=n(((e,t)=>{var n=Fr();t.exports=Ir()(n)})),Rr=n(((e,t)=>{var n=En(),r=Pr(),i=Lr();function a(e,t){return i(r(e,t,n),e+``)}t.exports=a})),zr=n(((e,t)=>{function n(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}t.exports=n})),Br=n(((e,t)=>{function n(e){return e!==e}t.exports=n})),Vr=n(((e,t)=>{function n(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}t.exports=n})),Hr=n(((e,t)=>{var n=zr(),r=Br(),i=Vr();function a(e,t,a){return t===t?i(e,t,a):n(e,r,a)}t.exports=a})),Ur=n(((e,t)=>{var n=Hr();function r(e,t){return!!(e!=null&&e.length)&&n(e,t,0)>-1}t.exports=r})),Wr=n(((e,t)=>{function n(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}t.exports=n})),Gr=n(((e,t)=>{function n(){}t.exports=n})),Kr=n(((e,t)=>{var n=en(),r=Gr(),i=Rn();t.exports=n&&1/i(new n([,-0]))[1]==1/0?function(e){return new n(e)}:r})),qr=n(((e,t)=>{var n=Nn(),r=Ur(),i=Wr(),a=Fn(),o=Kr(),s=Rn(),c=200;function l(e,t,l){var u=-1,d=r,f=e.length,p=!0,m=[],h=m;if(l)p=!1,d=i;else if(f>=c){var g=t?null:o(e);if(g)return s(g);p=!1,d=a,h=new n}else h=t?[]:m;outer:for(;++u<f;){var _=e[u],v=t?t(_):_;if(_=l||_!==0?_:0,p&&v===v){for(var y=h.length;y--;)if(h[y]===v)continue outer;t&&h.push(v),m.push(_)}else d(h,v,l)||(h!==m&&h.push(v),m.push(_))}return m}t.exports=l})),Jr=n(((e,t)=>{var n=Mt(),r=gt();function i(e){return r(e)&&n(e)}t.exports=i})),Yr=n(((e,t)=>{var n=Mr(),r=Rr(),i=qr(),a=Jr();t.exports=r(function(e){return i(n(e,1,a,!0))})})),Xr=n(((e,t)=>{var n=$n();function r(e,t){return n(t,function(t){return e[t]})}t.exports=r})),Zr=n(((e,t)=>{var n=Xr(),r=Nt();function i(e){return e==null?[]:n(e,r(e))}t.exports=i})),U=n(((t,n)=>{var r;if(typeof e==`function`)try{r={clone:yn(),constant:bn(),each:kn(),filter:mr(),has:gr(),isArray:H(),isEmpty:_r(),isFunction:ze(),isUndefined:vr(),keys:Nt(),map:br(),reduce:Cr(),size:kr(),transform:Ar(),union:Yr(),values:Zr()}}catch{}r||=window._,n.exports=r})),Qr=n(((e,t)=>{var n=U();t.exports=o;var r=`\0`,i=`\0`,a=``;function o(e){this._isDirected=!n.has(e,`directed`)||e.directed,this._isMultigraph=n.has(e,`multigraph`)?e.multigraph:!1,this._isCompound=n.has(e,`compound`)?e.compound:!1,this._label=void 0,this._defaultNodeLabelFn=n.constant(void 0),this._defaultEdgeLabelFn=n.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[i]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(e){return this._label=e,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(e){return n.isFunction(e)||(e=n.constant(e)),this._defaultNodeLabelFn=e,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return n.keys(this._nodes)},o.prototype.sources=function(){var e=this;return n.filter(this.nodes(),function(t){return n.isEmpty(e._in[t])})},o.prototype.sinks=function(){var e=this;return n.filter(this.nodes(),function(t){return n.isEmpty(e._out[t])})},o.prototype.setNodes=function(e,t){var r=arguments,i=this;return n.each(e,function(e){r.length>1?i.setNode(e,t):i.setNode(e)}),this},o.prototype.setNode=function(e,t){return n.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=i,this._children[e]={},this._children[i][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},o.prototype.node=function(e){return this._nodes[e]},o.prototype.hasNode=function(e){return n.has(this._nodes,e)},o.prototype.removeNode=function(e){var t=this;if(n.has(this._nodes,e)){var r=function(e){t.removeEdge(t._edgeObjs[e])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],n.each(this.children(e),function(e){t.setParent(e)}),delete this._children[e]),n.each(n.keys(this._in[e]),r),delete this._in[e],delete this._preds[e],n.each(n.keys(this._out[e]),r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},o.prototype.setParent=function(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(n.isUndefined(t))t=i;else{t+=``;for(var r=t;!n.isUndefined(r);r=this.parent(r))if(r===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this},o.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},o.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if(t!==i)return t}},o.prototype.children=function(e){if(n.isUndefined(e)&&(e=i),this._isCompound){var t=this._children[e];if(t)return n.keys(t)}else if(e===i)return this.nodes();else if(this.hasNode(e))return[]},o.prototype.predecessors=function(e){var t=this._preds[e];if(t)return n.keys(t)},o.prototype.successors=function(e){var t=this._sucs[e];if(t)return n.keys(t)},o.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return n.union(t,this.successors(e))},o.prototype.isLeaf=function(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0},o.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var r=this;n.each(this._nodes,function(n,r){e(r)&&t.setNode(r,n)}),n.each(this._edgeObjs,function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,r.edge(e))});var i={};function a(e){var n=r.parent(e);return n===void 0||t.hasNode(n)?(i[e]=n,n):n in i?i[n]:a(n)}return this._isCompound&&n.each(t.nodes(),function(e){t.setParent(e,a(e))}),t},o.prototype.setDefaultEdgeLabel=function(e){return n.isFunction(e)||(e=n.constant(e)),this._defaultEdgeLabelFn=e,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return n.values(this._edgeObjs)},o.prototype.setPath=function(e,t){var r=this,i=arguments;return n.reduce(e,function(e,n){return i.length>1?r.setEdge(e,n,t):r.setEdge(e,n),n}),this},o.prototype.setEdge=function(){var e,t,r,i,a=!1,o=arguments[0];typeof o==`object`&&o&&`v`in o?(e=o.v,t=o.w,r=o.name,arguments.length===2&&(i=arguments[1],a=!0)):(e=o,t=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),e=``+e,t=``+t,n.isUndefined(r)||(r=``+r);var c=l(this._isDirected,e,t,r);if(n.has(this._edgeLabels,c))return a&&(this._edgeLabels[c]=i),this;if(!n.isUndefined(r)&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[c]=a?i:this._defaultEdgeLabelFn(e,t,r);var d=u(this._isDirected,e,t,r);return e=d.v,t=d.w,Object.freeze(d),this._edgeObjs[c]=d,s(this._preds[t],e),s(this._sucs[e],t),this._in[t][c]=d,this._out[e][c]=d,this._edgeCount++,this},o.prototype.edge=function(e,t,n){var r=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,e,t,n);return this._edgeLabels[r]},o.prototype.hasEdge=function(e,t,r){var i=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,e,t,r);return n.has(this._edgeLabels,i)},o.prototype.removeEdge=function(e,t,n){var r=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],c(this._preds[t],e),c(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this},o.prototype.inEdges=function(e,t){var r=this._in[e];if(r){var i=n.values(r);return t?n.filter(i,function(e){return e.v===t}):i}},o.prototype.outEdges=function(e,t){var r=this._out[e];if(r){var i=n.values(r);return t?n.filter(i,function(e){return e.w===t}):i}},o.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))};function s(e,t){e[t]?e[t]++:e[t]=1}function c(e,t){--e[t]||delete e[t]}function l(e,t,i,o){var s=``+t,c=``+i;if(!e&&s>c){var l=s;s=c,c=l}return s+a+c+a+(n.isUndefined(o)?r:o)}function u(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function d(e,t){return l(e,t.v,t.w,t.name)}})),$r=n(((e,t)=>{t.exports=`2.1.8`})),ei=n(((e,t)=>{t.exports={Graph:Qr(),version:$r()}})),ti=n(((e,t)=>{var n=U(),r=Qr();t.exports={write:i,read:s};function i(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:a(e),edges:o(e)};return n.isUndefined(e.graph())||(t.value=n.clone(e.graph())),t}function a(e){return n.map(e.nodes(),function(t){var r=e.node(t),i=e.parent(t),a={v:t};return n.isUndefined(r)||(a.value=r),n.isUndefined(i)||(a.parent=i),a})}function o(e){return n.map(e.edges(),function(t){var r=e.edge(t),i={v:t.v,w:t.w};return n.isUndefined(t.name)||(i.name=t.name),n.isUndefined(r)||(i.value=r),i})}function s(e){var t=new r(e.options).setGraph(e.value);return n.each(e.nodes,function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),n.each(e.edges,function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}})),ni=n(((e,t)=>{var n=U();t.exports=r;function r(e){var t={},r=[],i;function a(r){n.has(t,r)||(t[r]=!0,i.push(r),n.each(e.successors(r),a),n.each(e.predecessors(r),a))}return n.each(e.nodes(),function(e){i=[],a(e),i.length&&r.push(i)}),r}})),ri=n(((e,t)=>{var n=U();t.exports=r;function r(){this._arr=[],this._keyIndices={}}r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(e){return e.key})},r.prototype.has=function(e){return n.has(this._keyIndices,e)},r.prototype.priority=function(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority},r.prototype.min=function(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key},r.prototype.add=function(e,t){var r=this._keyIndices;if(e=String(e),!n.has(r,e)){var i=this._arr,a=i.length;return r[e]=a,i.push({key:e,priority:t}),this._decrease(a),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key},r.prototype.decrease=function(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)},r.prototype._heapify=function(e){var t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))},r.prototype._decrease=function(e){for(var t=this._arr,n=t[e].priority,r;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r},r.prototype._swap=function(e,t){var n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}})),ii=n(((e,t)=>{var n=U(),r=ri();t.exports=a;var i=n.constant(1);function a(e,t,n,r){return o(e,String(t),n||i,r||function(t){return e.outEdges(t)})}function o(e,t,n,i){var a={},o=new r,s,c,l=function(e){var t=e.v===s?e.w:e.v,r=a[t],i=n(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l<r.distance&&(r.distance=l,r.predecessor=s,o.decrease(t,l))};for(e.nodes().forEach(function(e){var n=e===t?0:1/0;a[e]={distance:n},o.add(e,n)});o.size()>0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}})),ai=n(((e,t)=>{var n=ii(),r=U();t.exports=i;function i(e,t,i){return r.transform(e.nodes(),function(r,a){r[a]=n(e,a,t,i)},{})}})),oi=n(((e,t)=>{var n=U();t.exports=r;function r(e){var t=0,r=[],i={},a=[];function o(s){var c=i[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),e.successors(s).forEach(function(e){n.has(i,e)?i[e].onStack&&(c.lowlink=Math.min(c.lowlink,i[e].index)):(o(e),c.lowlink=Math.min(c.lowlink,i[e].lowlink))}),c.lowlink===c.index){var l=[],u;do u=r.pop(),i[u].onStack=!1,l.push(u);while(s!==u);a.push(l)}}return e.nodes().forEach(function(e){n.has(i,e)||o(e)}),a}})),si=n(((e,t)=>{var n=U(),r=oi();t.exports=i;function i(e){return n.filter(r(e),function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}})),ci=n(((e,t)=>{var n=U();t.exports=i;var r=n.constant(1);function i(e,t,n){return a(e,t||r,n||function(t){return e.outEdges(t)})}function a(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}})),li=n(((e,t)=>{var n=U();t.exports=r,r.CycleException=i;function r(e){var t={},r={},a=[];function o(s){if(n.has(r,s))throw new i;n.has(t,s)||(r[s]=!0,t[s]=!0,n.each(e.predecessors(s),o),delete r[s],a.push(s))}if(n.each(e.sinks(),o),n.size(t)!==e.nodeCount())throw new i;return a}function i(){}i.prototype=Error()})),ui=n(((e,t)=>{var n=li();t.exports=r;function r(e){try{n(e)}catch(e){if(e instanceof n.CycleException)return!1;throw e}return!0}})),di=n(((e,t)=>{var n=U();t.exports=r;function r(e,t,r){n.isArray(t)||(t=[t]);var a=(e.isDirected()?e.successors:e.neighbors).bind(e),o=[],s={};return n.each(t,function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i(e,t,r===`post`,s,a,o)}),o}function i(e,t,r,a,o,s){n.has(a,t)||(a[t]=!0,r||s.push(t),n.each(o(t),function(t){i(e,t,r,a,o,s)}),r&&s.push(t))}})),fi=n(((e,t)=>{var n=di();t.exports=r;function r(e,t){return n(e,t,`post`)}})),pi=n(((e,t)=>{var n=di();t.exports=r;function r(e,t){return n(e,t,`pre`)}})),mi=n(((e,t)=>{var n=U(),r=Qr(),i=ri();t.exports=a;function a(e,t){var a=new r,o={},s=new i,c;function l(e){var n=e.v===c?e.w:e.v,r=s.priority(n);if(r!==void 0){var i=t(e);i<r&&(o[n]=c,s.decrease(n,i))}}if(e.nodeCount()===0)return a;n.each(e.nodes(),function(e){s.add(e,1/0),a.setNode(e)}),s.decrease(e.nodes()[0],0);for(var u=!1;s.size()>0;){if(c=s.removeMin(),n.has(o,c))a.setEdge(c,o[c]);else if(u)throw Error(`Input graph is not connected: `+e);else u=!0;e.nodeEdges(c).forEach(l)}return a}})),hi=n(((e,t)=>{t.exports={components:ni(),dijkstra:ii(),dijkstraAll:ai(),findCycles:si(),floydWarshall:ci(),isAcyclic:ui(),postorder:fi(),preorder:pi(),prim:mi(),tarjan:oi(),topsort:li()}})),gi=n(((e,t)=>{var n=ei();t.exports={Graph:n.Graph,json:ti(),alg:hi(),version:n.version}})),W=n(((t,n)=>{var r;if(typeof e==`function`)try{r=gi()}catch{}r||=window.graphlib,n.exports=r})),_i=n(((e,t)=>{var n=vn(),r=1,i=4;function a(e){return n(e,r|i)}t.exports=a})),vi=n(((e,t)=>{var n=Se(),r=Mt(),i=xt(),a=V();function o(e,t,o){if(!a(o))return!1;var s=typeof t;return(s==`number`?r(o)&&i(t,o.length):s==`string`&&t in o)?n(o[t],e):!1}t.exports=o})),yi=n(((e,t)=>{var n=Rr(),r=Se(),i=vi(),a=Lt(),o=Object.prototype,s=o.hasOwnProperty;t.exports=n(function(e,t){e=Object(e);var n=-1,c=t.length,l=c>2?t[2]:void 0;for(l&&i(t[0],t[1],l)&&(c=1);++n<c;)for(var u=t[n],d=a(u),f=-1,p=d.length;++f<p;){var m=d[f],h=e[m];(h===void 0||r(h,o[m])&&!s.call(e,m))&&(e[m]=u[m])}return e})})),bi=n(((e,t)=>{var n=pr(),r=Mt(),i=Nt();function a(e){return function(t,a,o){var s=Object(t);if(!r(t)){var c=n(a,3);t=i(t),a=function(e){return c(s[e],e,s)}}var l=e(t,a,o);return l>-1?s[c?t[l]:l]:void 0}}t.exports=a})),xi=n(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),Si=n(((e,t)=>{var n=xi(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Ci=n(((e,t)=>{var n=Si(),r=V(),i=Jn(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),wi=n(((e,t)=>{var n=Ci(),r=1/0,i=17976931348623157e292;function a(e){return e?(e=n(e),e===r||e===-r?(e<0?-1:1)*i:e===e?e:0):e===0?e:0}t.exports=a})),Ti=n(((e,t)=>{var n=wi();function r(e){var t=n(e),r=t%1;return t===t?r?t-r:t:0}t.exports=r})),Ei=n(((e,t)=>{var n=zr(),r=pr(),i=Ti(),a=Math.max;function o(e,t,o){var s=e==null?0:e.length;if(!s)return-1;var c=o==null?0:i(o);return c<0&&(c=a(s+c,0)),n(e,r(t,3),c)}t.exports=o})),Di=n(((e,t)=>{t.exports=bi()(Ei())})),Oi=n(((e,t)=>{var n=Mr();function r(e){return e!=null&&e.length?n(e,1):[]}t.exports=r})),ki=n(((e,t)=>{var n=Sn(),r=Dn(),i=Lt();function a(e,t){return e==null?e:n(e,r(t),i)}t.exports=a})),Ai=n(((e,t)=>{function n(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}t.exports=n})),ji=n(((e,t)=>{var n=ft(),r=Cn(),i=pr();function a(e,t){var a={};return t=i(t,3),r(e,function(e,r,i){n(a,r,t(e,r,i))}),a}t.exports=a})),Mi=n(((e,t)=>{var n=Jn();function r(e,t,r){for(var i=-1,a=e.length;++i<a;){var o=e[i],s=t(o);if(s!=null&&(c===void 0?s===s&&!n(s):r(s,c)))var c=s,l=o}return l}t.exports=r})),Ni=n(((e,t)=>{function n(e,t){return e>t}t.exports=n})),Pi=n(((e,t)=>{var n=Mi(),r=Ni(),i=En();function a(e){return e&&e.length?n(e,i,r):void 0}t.exports=a})),Fi=n(((e,t)=>{var n=ft(),r=Se();function i(e,t,i){(i!==void 0&&!r(e[t],i)||i===void 0&&!(t in e))&&n(e,t,i)}t.exports=i})),Ii=n(((e,t)=>{var n=Re(),r=Kt(),i=gt(),a=`[object Object]`,o=Function.prototype,s=Object.prototype,c=o.toString,l=s.hasOwnProperty,u=c.call(Object);function d(e){if(!i(e)||n(e)!=a)return!1;var t=r(e);if(t===null)return!0;var o=l.call(t,`constructor`)&&t.constructor;return typeof o==`function`&&o instanceof o&&c.call(o)==u}t.exports=d})),Li=n(((e,t)=>{function n(e,t){if((t!==`constructor`||typeof e[t]!=`function`)&&t!=`__proto__`)return e[t]}t.exports=n})),Ri=n(((e,t)=>{var n=mt(),r=Lt();function i(e){return n(e,r(e))}t.exports=i})),zi=n(((e,t)=>{var n=Fi(),r=zt(),i=un(),a=Bt(),o=pn(),s=vt(),c=H(),l=Jr(),u=bt(),d=ze(),f=V(),p=Ii(),m=Et(),h=Li(),g=Ri();function _(e,t,_,v,y,b,x){var S=h(e,_),C=h(t,_),w=x.get(C);if(w){n(e,_,w);return}var T=b?b(S,C,_+``,e,t,x):void 0,E=T===void 0;if(E){var D=c(C),O=!D&&u(C),k=!D&&!O&&m(C);T=C,D||O||k?c(S)?T=S:l(S)?T=a(S):O?(E=!1,T=r(C,!0)):k?(E=!1,T=i(C,!0)):T=[]:p(C)||s(C)?(T=S,s(S)?T=g(S):(!f(S)||d(S))&&(T=o(C))):E=!1}E&&(x.set(C,T),y(T,C,v,b,x),x.delete(C)),n(e,_,T)}t.exports=_})),Bi=n(((e,t)=>{var n=lt(),r=Fi(),i=Sn(),a=zi(),o=V(),s=Lt(),c=Li();function l(e,t,u,d,f){e!==t&&i(t,function(i,s){if(f||=new n,o(i))a(e,t,s,u,l,d,f);else{var p=d?d(c(e,s),i,s+``,e,t,f):void 0;p===void 0&&(p=i),r(e,s,p)}},s)}t.exports=l})),Vi=n(((e,t)=>{var n=Rr(),r=vi();function i(e){return n(function(t,n){var i=-1,a=n.length,o=a>1?n[a-1]:void 0,s=a>2?n[2]:void 0;for(o=e.length>3&&typeof o==`function`?(a--,o):void 0,s&&r(n[0],n[1],s)&&(o=a<3?void 0:o,a=1),t=Object(t);++i<a;){var c=n[i];c&&e(t,c,i,o)}return t})}t.exports=i})),Hi=n(((e,t)=>{var n=Bi();t.exports=Vi()(function(e,t,r){n(e,t,r)})})),Ui=n(((e,t)=>{function n(e,t){return e<t}t.exports=n})),Wi=n(((e,t)=>{var n=Mi(),r=Ui(),i=En();function a(e){return e&&e.length?n(e,i,r):void 0}t.exports=a})),Gi=n(((e,t)=>{var n=Mi(),r=pr(),i=Ui();function a(e,t){return e&&e.length?n(e,r(t,2),i):void 0}t.exports=a})),Ki=n(((e,t)=>{var n=Pe();t.exports=function(){return n.Date.now()}})),qi=n(((e,t)=>{var n=pt(),r=nr(),i=xt(),a=V(),o=rr();function s(e,t,s,c){if(!a(e))return e;t=r(t,e);for(var l=-1,u=t.length,d=u-1,f=e;f!=null&&++l<u;){var p=o(t[l]),m=s;if(p===`__proto__`||p===`constructor`||p===`prototype`)return e;if(l!=d){var h=f[p];m=c?c(h,p,f):void 0,m===void 0&&(m=a(h)?h:i(t[l+1])?[]:{})}n(f,p,m),f=f[p]}return e}t.exports=s})),Ji=n(((e,t)=>{var n=ir(),r=qi(),i=nr();function a(e,t,a){for(var o=-1,s=t.length,c={};++o<s;){var l=t[o],u=n(e,l);a(u,l)&&r(c,i(l,e),u)}return c}t.exports=a})),Yi=n(((e,t)=>{var n=Ji(),r=cr();function i(e,t){return n(e,t,function(t,n){return r(e,n)})}t.exports=i})),Xi=n(((e,t)=>{var n=Oi(),r=Pr(),i=Lr();function a(e){return i(r(e,void 0,n),e+``)}t.exports=a})),Zi=n(((e,t)=>{var n=Yi();t.exports=Xi()(function(e,t){return e==null?{}:n(e,t)})})),Qi=n(((e,t)=>{var n=Math.ceil,r=Math.max;function i(e,t,i,a){for(var o=-1,s=r(n((t-e)/(i||1)),0),c=Array(s);s--;)c[a?s:++o]=e,e+=i;return c}t.exports=i})),$i=n(((e,t)=>{var n=Qi(),r=vi(),i=wi();function a(e){return function(t,a,o){return o&&typeof o!=`number`&&r(t,a,o)&&(a=o=void 0),t=i(t),a===void 0?(a=t,t=0):a=i(a),o=o===void 0?t<a?1:-1:i(o),n(t,a,o,e)}}t.exports=a})),ea=n(((e,t)=>{t.exports=$i()()})),ta=n(((e,t)=>{function n(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}t.exports=n})),na=n(((e,t)=>{var n=Jn();function r(e,t){if(e!==t){var r=e!==void 0,i=e===null,a=e===e,o=n(e),s=t!==void 0,c=t===null,l=t===t,u=n(t);if(!c&&!u&&!o&&e>t||o&&s&&l&&!c&&!u||i&&s&&l||!r&&l||!a)return 1;if(!i&&!o&&!u&&e<t||u&&r&&a&&!i&&!o||c&&r&&a||!s&&a||!l)return-1}return 0}t.exports=r})),ra=n(((e,t)=>{var n=na();function r(e,t,r){for(var i=-1,a=e.criteria,o=t.criteria,s=a.length,c=r.length;++i<s;){var l=n(a[i],o[i]);if(l)return i>=c?l:l*(r[i]==`desc`?-1:1)}return e.index-t.index}t.exports=r})),ia=n(((e,t)=>{var n=$n(),r=ir(),i=pr(),a=yr(),o=ta(),s=wt(),c=ra(),l=En(),u=H();function d(e,t,d){t=t.length?n(t,function(e){return u(e)?function(t){return r(t,e.length===1?e[0]:e)}:e}):[l];var f=-1;return t=n(t,s(i)),o(a(e,function(e,r,i){return{criteria:n(t,function(t){return t(e)}),index:++f,value:e}}),function(e,t){return c(e,t,d)})}t.exports=d})),aa=n(((e,t)=>{var n=Mr(),r=ia(),i=Rr(),a=vi();t.exports=i(function(e,t){if(e==null)return[];var i=t.length;return i>1&&a(e,t[0],t[1])?t=[]:i>2&&a(t[0],t[1],t[2])&&(t=[t[0]]),r(e,n(t,1),[])})})),oa=n(((e,t)=>{var n=tr(),r=0;function i(e){var t=++r;return n(e)+t}t.exports=i})),sa=n(((e,t)=>{function n(e,t,n){for(var r=-1,i=e.length,a=t.length,o={};++r<i;){var s=r<a?t[r]:void 0;n(o,e[r],s)}return o}t.exports=n})),ca=n(((e,t)=>{var n=pt(),r=sa();function i(e,t){return r(e||[],t||[],n)}t.exports=i})),G=n(((t,n)=>{var r;if(typeof e==`function`)try{r={cloneDeep:_i(),constant:bn(),defaults:yi(),each:kn(),filter:mr(),find:Di(),flatten:Oi(),forEach:On(),forIn:ki(),has:gr(),isUndefined:vr(),last:Ai(),map:br(),mapValues:ji(),max:Pi(),merge:Hi(),min:Wi(),minBy:Gi(),now:Ki(),pick:Zi(),range:ea(),reduce:Cr(),sortBy:aa(),uniqueId:oa(),values:Zr(),zipObject:ca()}}catch{}r||=window._,n.exports=r})),la=n(((e,t)=>{t.exports=n;function n(){var e={};e._next=e._prev=e,this._sentinel=e}n.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return r(t),t},n.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t},n.prototype.toString=function(){for(var e=[],t=this._sentinel,n=t._prev;n!==t;)e.push(JSON.stringify(n,i)),n=n._prev;return`[`+e.join(`, `)+`]`};function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function i(e,t){if(e!==`_next`&&e!==`_prev`)return t}})),ua=n(((e,t)=>{var n=G(),r=W().Graph,i=la();t.exports=o;var a=n.constant(1);function o(e,t){if(e.nodeCount()<=1)return[];var r=l(e,t||a),i=s(r.graph,r.buckets,r.zeroIdx);return n.flatten(n.map(i,function(t){return e.outEdges(t.v,t.w)}),!0)}function s(e,t,n){for(var r=[],i=t[t.length-1],a=t[0],o;e.nodeCount();){for(;o=a.dequeue();)c(e,t,n,o);for(;o=i.dequeue();)c(e,t,n,o);if(e.nodeCount()){for(var s=t.length-2;s>0;--s)if(o=t[s].dequeue(),o){r=r.concat(c(e,t,n,o,!0));break}}}return r}function c(e,t,r,i,a){var o=a?[]:void 0;return n.forEach(e.inEdges(i.v),function(n){var i=e.edge(n),s=e.node(n.v);a&&o.push({v:n.v,w:n.w}),s.out-=i,u(t,r,s)}),n.forEach(e.outEdges(i.v),function(n){var i=e.edge(n),a=n.w,o=e.node(a);o.in-=i,u(t,r,o)}),e.removeNode(i.v),o}function l(e,t){var a=new r,o=0,s=0;n.forEach(e.nodes(),function(e){a.setNode(e,{v:e,in:0,out:0})}),n.forEach(e.edges(),function(e){var n=a.edge(e.v,e.w)||0,r=t(e),i=n+r;a.setEdge(e.v,e.w,i),s=Math.max(s,a.node(e.v).out+=r),o=Math.max(o,a.node(e.w).in+=r)});var c=n.range(s+o+3).map(function(){return new i}),l=o+1;return n.forEach(a.nodes(),function(e){u(c,l,a.node(e))}),{graph:a,buckets:c,zeroIdx:l}}function u(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}})),da=n(((e,t)=>{var n=G(),r=ua();t.exports={run:i,undo:o};function i(e){var t=e.graph().acyclicer===`greedy`?r(e,i(e)):a(e);n.forEach(t,function(t){var r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,n.uniqueId(`rev`))});function i(e){return function(t){return e.edge(t).weight}}}function a(e){var t=[],r={},i={};function a(o){n.has(i,o)||(i[o]=!0,r[o]=!0,n.forEach(e.outEdges(o),function(e){n.has(r,e.w)?t.push(e):a(e.w)}),delete r[o])}return n.forEach(e.nodes(),a),t}function o(e){n.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}})),K=n(((e,t)=>{var n=G(),r=W().Graph;t.exports={addDummyNode:i,simplify:a,asNonCompoundGraph:o,successorWeights:s,predecessorWeights:c,intersectRect:l,buildLayerMatrix:u,normalizeRanks:d,removeEmptyRanks:f,addBorderNode:p,maxRank:m,partition:h,time:g,notime:_};function i(e,t,r,i){var a;do a=n.uniqueId(i);while(e.hasNode(a));return r.dummy=t,e.setNode(a,r),a}function a(e){var t=new r().setGraph(e.graph());return n.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),n.forEach(e.edges(),function(n){var r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function o(e){var t=new r({multigraph:e.isMultigraph()}).setGraph(e.graph());return n.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),n.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function s(e){var t=n.map(e.nodes(),function(t){var r={};return n.forEach(e.outEdges(t),function(t){r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return n.zipObject(e.nodes(),t)}function c(e){var t=n.map(e.nodes(),function(t){var r={};return n.forEach(e.inEdges(t),function(t){r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return n.zipObject(e.nodes(),t)}function l(e,t){var n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);var c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function u(e){var t=n.map(n.range(m(e)+1),function(){return[]});return n.forEach(e.nodes(),function(r){var i=e.node(r),a=i.rank;n.isUndefined(a)||(t[a][i.order]=r)}),t}function d(e){var t=n.min(n.map(e.nodes(),function(t){return e.node(t).rank}));n.forEach(e.nodes(),function(r){var i=e.node(r);n.has(i,`rank`)&&(i.rank-=t)})}function f(e){var t=n.min(n.map(e.nodes(),function(t){return e.node(t).rank})),r=[];n.forEach(e.nodes(),function(n){var i=e.node(n).rank-t;r[i]||(r[i]=[]),r[i].push(n)});var i=0,a=e.graph().nodeRankFactor;n.forEach(r,function(t,r){n.isUndefined(t)&&r%a!==0?--i:i&&n.forEach(t,function(t){e.node(t).rank+=i})})}function p(e,t,n,r){var a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=r),i(e,`border`,a,t)}function m(e){return n.max(n.map(e.nodes(),function(t){var r=e.node(t).rank;if(!n.isUndefined(r))return r}))}function h(e,t){var r={lhs:[],rhs:[]};return n.forEach(e,function(e){t(e)?r.lhs.push(e):r.rhs.push(e)}),r}function g(e,t){var r=n.now();try{return t()}finally{console.log(e+` time: `+(n.now()-r)+`ms`)}}function _(e,t){return t()}})),fa=n(((e,t)=>{var n=G(),r=K();t.exports={run:i,undo:o};function i(e){e.graph().dummyChains=[],n.forEach(e.edges(),function(t){a(e,t)})}function a(e,t){var n=t.v,i=e.node(n).rank,a=t.w,o=e.node(a).rank,s=t.name,c=e.edge(t),l=c.labelRank;if(o!==i+1){e.removeEdge(t);var u,d,f;for(f=0,++i;i<o;++f,++i)c.points=[],d={width:0,height:0,edgeLabel:c,edgeObj:t,rank:i},u=r.addDummyNode(e,`edge`,d,`_d`),i===l&&(d.width=c.width,d.height=c.height,d.dummy=`edge-label`,d.labelpos=c.labelpos),e.setEdge(n,u,{weight:c.weight},s),f===0&&e.graph().dummyChains.push(u),n=u;e.setEdge(n,a,{weight:c.weight},s)}}function o(e){n.forEach(e.graph().dummyChains,function(t){var n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}})),pa=n(((e,t)=>{var n=G();t.exports={longestPath:r,slack:i};function r(e){var t={};function r(i){var a=e.node(i);if(n.has(t,i))return a.rank;t[i]=!0;var o=n.min(n.map(e.outEdges(i),function(t){return r(t.w)-e.edge(t).minlen}));return(o===1/0||o==null)&&(o=0),a.rank=o}n.forEach(e.sources(),r)}function i(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}})),ma=n(((e,t)=>{var n=G(),r=W().Graph,i=pa().slack;t.exports=a;function a(e){var t=new r({directed:!1}),n=e.nodes()[0],a=e.nodeCount();t.setNode(n,{});for(var l,u;o(t,e)<a;)l=s(t,e),u=t.hasNode(l.v)?i(e,l):-i(e,l),c(t,e,u);return t}function o(e,t){function r(a){n.forEach(t.nodeEdges(a),function(n){var o=n.v,s=a===o?n.w:o;!e.hasNode(s)&&!i(t,n)&&(e.setNode(s,{}),e.setEdge(a,s,{}),r(s))})}return n.forEach(e.nodes(),r),e.nodeCount()}function s(e,t){return n.minBy(t.edges(),function(n){if(e.hasNode(n.v)!==e.hasNode(n.w))return i(t,n)})}function c(e,t,r){n.forEach(e.nodes(),function(e){t.node(e).rank+=r})}})),ha=n(((e,t)=>{var n=G(),r=ma(),i=pa().slack,a=pa().longestPath,o=W().alg.preorder,s=W().alg.postorder,c=K().simplify;t.exports=l,l.initLowLimValues=p,l.initCutValues=u,l.calcCutValue=f,l.leaveEdge=h,l.enterEdge=g,l.exchangeEdges=_;function l(e){e=c(e),a(e);var t=r(e);p(t),u(t,e);for(var n,i;n=h(t);)i=g(t,e,n),_(t,e,n,i)}function u(e,t){var r=s(e,e.nodes());r=r.slice(0,r.length-1),n.forEach(r,function(n){d(e,t,n)})}function d(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=f(e,t,n)}function f(e,t,r){var i=e.node(r).parent,a=!0,o=t.edge(r,i),s=0;return o||=(a=!1,t.edge(i,r)),s=o.weight,n.forEach(t.nodeEdges(r),function(n){var o=n.v===r,c=o?n.w:n.v;if(c!==i){var l=o===a,u=t.edge(n).weight;if(s+=l?u:-u,y(e,r,c)){var d=e.edge(r,c).cutvalue;s+=l?-d:d}}}),s}function p(e,t){arguments.length<2&&(t=e.nodes()[0]),m(e,{},1,t)}function m(e,t,r,i,a){var o=r,s=e.node(i);return t[i]=!0,n.forEach(e.neighbors(i),function(a){n.has(t,a)||(r=m(e,t,r,a,i))}),s.low=o,s.lim=r++,a?s.parent=a:delete s.parent,r}function h(e){return n.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function g(e,t,r){var a=r.v,o=r.w;t.hasEdge(a,o)||(a=r.w,o=r.v);var s=e.node(a),c=e.node(o),l=s,u=!1;s.lim>c.lim&&(l=c,u=!0);var d=n.filter(t.edges(),function(t){return u===b(e,e.node(t.v),l)&&u!==b(e,e.node(t.w),l)});return n.minBy(d,function(e){return i(t,e)})}function _(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),p(e),u(e,t),v(e,t)}function v(e,t){var r=o(e,n.find(e.nodes(),function(e){return!t.node(e).parent}));r=r.slice(1),n.forEach(r,function(n){var r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function y(e,t,n){return e.hasEdge(t,n)}function b(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}})),ga=n(((e,t)=>{var n=pa().longestPath,r=ma(),i=ha();t.exports=a;function a(e){switch(e.graph().ranker){case`network-simplex`:c(e);break;case`tight-tree`:s(e);break;case`longest-path`:o(e);break;default:c(e)}}var o=n;function s(e){n(e),r(e)}function c(e){i(e)}})),_a=n(((e,t)=>{var n=G();t.exports=r;function r(e){var t=a(e);n.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),a=r.edgeObj,o=i(e,t,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;n!==a.w;){if(r=e.node(n),d){for(;(u=s[l])!==c&&e.node(u).maxRank<r.rank;)l++;u===c&&(d=!1)}if(!d){for(;l<s.length-1&&e.node(u=s[l+1]).minRank<=r.rank;)l++;u=s[l]}e.setParent(n,u),n=e.successors(n)[0]}})}function i(e,t,n,r){var i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c=n,l;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function a(e){var t={},r=0;function i(a){var o=r;n.forEach(e.children(a),i),t[a]={low:o,lim:r++}}return n.forEach(e.children(),i),t}})),va=n(((e,t)=>{var n=G(),r=K();t.exports={run:i,cleanup:c};function i(e){var t=r.addDummyNode(e,`root`,{},`_root`),i=o(e),c=n.max(n.values(i))-1,l=2*c+1;e.graph().nestingRoot=t,n.forEach(e.edges(),function(t){e.edge(t).minlen*=l});var u=s(e)+1;n.forEach(e.children(),function(n){a(e,t,l,u,c,i,n)}),e.graph().nodeRankFactor=l}function a(e,t,i,o,s,c,l){var u=e.children(l);if(!u.length){l!==t&&e.setEdge(t,l,{weight:0,minlen:i});return}var d=r.addBorderNode(e,`_bt`),f=r.addBorderNode(e,`_bb`),p=e.node(l);e.setParent(d,l),p.borderTop=d,e.setParent(f,l),p.borderBottom=f,n.forEach(u,function(n){a(e,t,i,o,s,c,n);var r=e.node(n),u=r.borderTop?r.borderTop:n,p=r.borderBottom?r.borderBottom:n,m=r.borderTop?o:2*o,h=u===p?s-c[l]+1:1;e.setEdge(d,u,{weight:m,minlen:h,nestingEdge:!0}),e.setEdge(p,f,{weight:m,minlen:h,nestingEdge:!0})}),e.parent(l)||e.setEdge(t,d,{weight:0,minlen:s+c[l]})}function o(e){var t={};function r(i,a){var o=e.children(i);o&&o.length&&n.forEach(o,function(e){r(e,a+1)}),t[i]=a}return n.forEach(e.children(),function(e){r(e,1)}),t}function s(e){return n.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function c(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,n.forEach(e.edges(),function(t){e.edge(t).nestingEdge&&e.removeEdge(t)})}})),ya=n(((e,t)=>{var n=G(),r=K();t.exports=i;function i(e){function t(r){var i=e.children(r),o=e.node(r);if(i.length&&n.forEach(i,t),n.has(o,`minRank`)){o.borderLeft=[],o.borderRight=[];for(var s=o.minRank,c=o.maxRank+1;s<c;++s)a(e,`borderLeft`,`_bl`,r,o,s),a(e,`borderRight`,`_br`,r,o,s)}}n.forEach(e.children(),t)}function a(e,t,n,i,a,o){var s={width:0,height:0,rank:o,borderType:t},c=a[t][o-1],l=r.addDummyNode(e,`border`,s,n);a[t][o]=l,e.setParent(l,i),c&&e.setEdge(c,l,{weight:1})}})),ba=n(((e,t)=>{var n=G();t.exports={adjust:r,undo:i};function r(e){var t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&a(e)}function i(e){var t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&s(e),(t===`lr`||t===`rl`)&&(l(e),a(e))}function a(e){n.forEach(e.nodes(),function(t){o(e.node(t))}),n.forEach(e.edges(),function(t){o(e.edge(t))})}function o(e){var t=e.width;e.width=e.height,e.height=t}function s(e){n.forEach(e.nodes(),function(t){c(e.node(t))}),n.forEach(e.edges(),function(t){var r=e.edge(t);n.forEach(r.points,c),n.has(r,`y`)&&c(r)})}function c(e){e.y=-e.y}function l(e){n.forEach(e.nodes(),function(t){u(e.node(t))}),n.forEach(e.edges(),function(t){var r=e.edge(t);n.forEach(r.points,u),n.has(r,`x`)&&u(r)})}function u(e){var t=e.x;e.x=e.y,e.y=t}})),xa=n(((e,t)=>{var n=G();t.exports=r;function r(e){var t={},r=n.filter(e.nodes(),function(t){return!e.children(t).length}),i=n.max(n.map(r,function(t){return e.node(t).rank})),a=n.map(n.range(i+1),function(){return[]});function o(r){n.has(t,r)||(t[r]=!0,a[e.node(r).rank].push(r),n.forEach(e.successors(r),o))}var s=n.sortBy(r,function(t){return e.node(t).rank});return n.forEach(s,o),a}})),Sa=n(((e,t)=>{var n=G();t.exports=r;function r(e,t){for(var n=0,r=1;r<t.length;++r)n+=i(e,t[r-1],t[r]);return n}function i(e,t,r){for(var i=n.zipObject(r,n.map(r,function(e,t){return t})),a=n.flatten(n.map(t,function(t){return n.sortBy(n.map(e.outEdges(t),function(t){return{pos:i[t.w],weight:e.edge(t).weight}}),`pos`)}),!0),o=1;o<r.length;)o<<=1;var s=2*o-1;--o;var c=n.map(Array(s),function(){return 0}),l=0;return n.forEach(a.forEach(function(e){var t=e.pos+o;c[t]+=e.weight;for(var n=0;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n})),l}})),Ca=n(((e,t)=>{var n=G();t.exports=r;function r(e,t){return n.map(t,function(t){var r=e.inEdges(t);if(r.length){var i=n.reduce(r,function(t,n){var r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:i.sum/i.weight,weight:i.weight}}return{v:t}})}})),wa=n(((e,t)=>{var n=G();t.exports=r;function r(e,t){var r={};return n.forEach(e,function(e,t){var i=r[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};n.isUndefined(e.barycenter)||(i.barycenter=e.barycenter,i.weight=e.weight)}),n.forEach(t.edges(),function(e){var t=r[e.v],i=r[e.w];!n.isUndefined(t)&&!n.isUndefined(i)&&(i.indegree++,t.out.push(r[e.w]))}),i(n.filter(r,function(e){return!e.indegree}))}function i(e){var t=[];function r(e){return function(t){t.merged||(n.isUndefined(t.barycenter)||n.isUndefined(e.barycenter)||t.barycenter>=e.barycenter)&&a(e,t)}}function i(t){return function(n){n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){var o=e.pop();t.push(o),n.forEach(o.in.reverse(),r(o)),n.forEach(o.out,i(o))}return n.map(n.filter(t,function(e){return!e.merged}),function(e){return n.pick(e,[`vs`,`i`,`barycenter`,`weight`])})}function a(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}})),Ta=n(((e,t)=>{var n=G(),r=K();t.exports=i;function i(e,t){var i=r.partition(e,function(e){return n.has(e,`barycenter`)}),s=i.lhs,c=n.sortBy(i.rhs,function(e){return-e.i}),l=[],u=0,d=0,f=0;s.sort(o(!!t)),f=a(l,c,f),n.forEach(s,function(e){f+=e.vs.length,l.push(e.vs),u+=e.barycenter*e.weight,d+=e.weight,f=a(l,c,f)});var p={vs:n.flatten(l,!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function a(e,t,r){for(var i;t.length&&(i=n.last(t)).i<=r;)t.pop(),e.push(i.vs),r++;return r}function o(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}})),Ea=n(((e,t)=>{var n=G(),r=Ca(),i=wa(),a=Ta();t.exports=o;function o(e,t,l,u){var d=e.children(t),f=e.node(t),p=f?f.borderLeft:void 0,m=f?f.borderRight:void 0,h={};p&&(d=n.filter(d,function(e){return e!==p&&e!==m}));var g=r(e,d);n.forEach(g,function(t){if(e.children(t.v).length){var r=o(e,t.v,l,u);h[t.v]=r,n.has(r,`barycenter`)&&c(t,r)}});var _=i(g,l);s(_,h);var v=a(_,u);if(p&&(v.vs=n.flatten([p,v.vs,m],!0),e.predecessors(p).length)){var y=e.node(e.predecessors(p)[0]),b=e.node(e.predecessors(m)[0]);n.has(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+y.order+b.order)/(v.weight+2),v.weight+=2}return v}function s(e,t){n.forEach(e,function(e){e.vs=n.flatten(e.vs.map(function(e){return t[e]?t[e].vs:e}),!0)})}function c(e,t){n.isUndefined(e.barycenter)?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}})),Da=n(((e,t)=>{var n=G(),r=W().Graph;t.exports=i;function i(e,t,i){var o=a(e),s=new r({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(function(t){return e.node(t)});return n.forEach(e.nodes(),function(r){var a=e.node(r),c=e.parent(r);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(s.setNode(r),s.setParent(r,c||o),n.forEach(e[i](r),function(t){var i=t.v===r?t.w:t.v,a=s.edge(i,r),o=n.isUndefined(a)?0:a.weight;s.setEdge(i,r,{weight:e.edge(t).weight+o})}),n.has(a,`minRank`)&&s.setNode(r,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),s}function a(e){for(var t;e.hasNode(t=n.uniqueId(`_root`)););return t}})),Oa=n(((e,t)=>{var n=G();t.exports=r;function r(e,t,r){var i={},a;n.forEach(r,function(n){for(var r=e.parent(n),o,s;r;){if(o=e.parent(r),o?(s=i[o],i[o]=r):(s=a,a=r),s&&s!==r){t.setEdge(s,r);return}r=o}})}})),ka=n(((e,t)=>{var n=G(),r=xa(),i=Sa(),a=Ea(),o=Da(),s=Oa(),c=W().Graph,l=K();t.exports=u;function u(e){var t=l.maxRank(e),a=d(e,n.range(1,t+1),`inEdges`),o=d(e,n.range(t-1,-1,-1),`outEdges`),s=r(e);p(e,s);for(var c=1/0,u,m=0,h=0;h<4;++m,++h){f(m%2?a:o,m%4>=2),s=l.buildLayerMatrix(e);var g=i(e,s);g<c&&(h=0,u=n.cloneDeep(s),c=g)}p(e,u)}function d(e,t,r){return n.map(t,function(t){return o(e,t,r)})}function f(e,t){var r=new c;n.forEach(e,function(e){var i=e.graph().root,o=a(e,i,r,t);n.forEach(o.vs,function(t,n){e.node(t).order=n}),s(e,r,o.vs)})}function p(e,t){n.forEach(t,function(t){n.forEach(t,function(t,n){e.node(t).order=n})})}})),Aa=n(((e,t)=>{var n=G(),r=W().Graph,i=K();t.exports={positionX:g,findType1Conflicts:a,findType2Conflicts:o,addConflict:c,hasConflict:l,verticalAlignment:u,horizontalCompaction:d,alignCoordinates:m,findSmallestWidthAlignment:p,balance:h};function a(e,t){var r={};function i(t,i){var a=0,o=0,l=t.length,u=n.last(i);return n.forEach(i,function(t,d){var f=s(e,t),p=f?e.node(f).order:l;(f||t===u)&&(n.forEach(i.slice(o,d+1),function(t){n.forEach(e.predecessors(t),function(n){var i=e.node(n),o=i.order;(o<a||p<o)&&!(i.dummy&&e.node(t).dummy)&&c(r,n,t)})}),o=d+1,a=p)}),i}return n.reduce(t,i),r}function o(e,t){var r={};function i(t,i,a,o,s){var l;n.forEach(n.range(i,a),function(i){l=t[i],e.node(l).dummy&&n.forEach(e.predecessors(l),function(t){var n=e.node(t);n.dummy&&(n.order<o||n.order>s)&&c(r,t,l)})})}function a(t,r){var a=-1,o,s=0;return n.forEach(r,function(n,c){if(e.node(n).dummy===`border`){var l=e.predecessors(n);l.length&&(o=e.node(l[0]).order,i(r,s,c,a,o),s=c,a=o)}i(r,s,r.length,o,t.length)}),r}return n.reduce(t,a),r}function s(e,t){if(e.node(t).dummy)return n.find(e.predecessors(t),function(t){return e.node(t).dummy})}function c(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function l(e,t,r){if(t>r){var i=t;t=r,r=i}return n.has(e[t],r)}function u(e,t,r,i){var a={},o={},s={};return n.forEach(t,function(e){n.forEach(e,function(e,t){a[e]=e,o[e]=e,s[e]=t})}),n.forEach(t,function(e){var t=-1;n.forEach(e,function(e){var c=i(e);if(c.length){c=n.sortBy(c,function(e){return s[e]});for(var u=(c.length-1)/2,d=Math.floor(u),f=Math.ceil(u);d<=f;++d){var p=c[d];o[e]===e&&t<s[p]&&!l(r,e,p)&&(o[p]=e,o[e]=a[e]=a[p],t=s[p])}}})}),{root:a,align:o}}function d(e,t,r,i,a){var o={},s=f(e,t,r,a),c=a?`borderLeft`:`borderRight`;function l(e,t){for(var n=s.nodes(),r=n.pop(),i={};r;)i[r]?e(r):(i[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}function u(e){o[e]=s.inEdges(e).reduce(function(e,t){return Math.max(e,o[t.v]+s.edge(t))},0)}function d(t){var n=s.outEdges(t).reduce(function(e,t){return Math.min(e,o[t.w]-s.edge(t))},1/0),r=e.node(t);n!==1/0&&r.borderType!==c&&(o[t]=Math.max(o[t],n))}return l(u,s.predecessors.bind(s)),l(d,s.successors.bind(s)),n.forEach(i,function(e){o[e]=o[r[e]]}),o}function f(e,t,i,a){var o=new r,s=e.graph(),c=_(s.nodesep,s.edgesep,a);return n.forEach(t,function(t){var r;n.forEach(t,function(t){var n=i[t];if(o.setNode(n),r){var a=i[r],s=o.edge(a,n);o.setEdge(a,n,Math.max(c(e,t,r),s||0))}r=t})}),o}function p(e,t){return n.minBy(n.values(t),function(t){var r=-1/0,i=1/0;return n.forIn(t,function(t,n){var a=v(e,n)/2;r=Math.max(t+a,r),i=Math.min(t-a,i)}),r-i})}function m(e,t){var r=n.values(t),i=n.min(r),a=n.max(r);n.forEach([`u`,`d`],function(r){n.forEach([`l`,`r`],function(o){var s=r+o,c=e[s],l;if(c!==t){var u=n.values(c);l=o===`l`?i-n.min(u):a-n.max(u),l&&(e[s]=n.mapValues(c,function(e){return e+l}))}})})}function h(e,t){return n.mapValues(e.ul,function(r,i){if(t)return e[t.toLowerCase()][i];var a=n.sortBy(n.map(e,i));return(a[1]+a[2])/2})}function g(e){var t=i.buildLayerMatrix(e),r=n.merge(a(e,t),o(e,t)),s={},c;return n.forEach([`u`,`d`],function(i){c=i===`u`?t:n.values(t).reverse(),n.forEach([`l`,`r`],function(t){t===`r`&&(c=n.map(c,function(e){return n.values(e).reverse()}));var a=(i===`u`?e.predecessors:e.successors).bind(e),o=u(e,c,r,a),l=d(e,c,o.root,o.align,t===`r`);t===`r`&&(l=n.mapValues(l,function(e){return-e})),s[i+t]=l})}),m(s,p(e,s)),h(s,e.graph().align)}function _(e,t,r){return function(i,a,o){var s=i.node(a),c=i.node(o),l=0,u;if(l+=s.width/2,n.has(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:u=-s.width/2;break;case`r`:u=s.width/2}if(u&&(l+=r?u:-u),u=0,l+=(s.dummy?t:e)/2,l+=(c.dummy?t:e)/2,l+=c.width/2,n.has(c,`labelpos`))switch(c.labelpos.toLowerCase()){case`l`:u=c.width/2;break;case`r`:u=-c.width/2}return u&&(l+=r?u:-u),u=0,l}}function v(e,t){return e.node(t).width}})),ja=n(((e,t)=>{var n=G(),r=K(),i=Aa().positionX;t.exports=a;function a(e){e=r.asNonCompoundGraph(e),o(e),n.forEach(i(e),function(t,n){e.node(n).x=t})}function o(e){var t=r.buildLayerMatrix(e),i=e.graph().ranksep,a=0;n.forEach(t,function(t){var r=n.max(n.map(t,function(t){return e.node(t).height}));n.forEach(t,function(t){e.node(t).y=a+r/2}),a+=r+i})}})),Ma=n(((e,t)=>{var n=G(),r=da(),i=fa(),a=ga(),o=K().normalizeRanks,s=_a(),c=K().removeEmptyRanks,l=va(),u=ya(),d=ba(),f=ka(),p=ja(),m=K(),h=W().Graph;t.exports=g;function g(e,t){var n=t&&t.debugTiming?m.time:m.notime;n(`layout`,function(){var t=n(` buildLayoutGraph`,function(){return D(e)});n(` runLayout`,function(){_(t,n)}),n(` updateInputGraph`,function(){v(e,t)})})}function _(e,t){t(` makeSpaceForEdgeLabels`,function(){O(e)}),t(` removeSelfEdges`,function(){P(e)}),t(` acyclic`,function(){r.run(e)}),t(` nestingGraph.run`,function(){l.run(e)}),t(` rank`,function(){a(m.asNonCompoundGraph(e))}),t(` injectEdgeLabelProxies`,function(){k(e)}),t(` removeEmptyRanks`,function(){c(e)}),t(` nestingGraph.cleanup`,function(){l.cleanup(e)}),t(` normalizeRanks`,function(){o(e)}),t(` assignRankMinMax`,function(){A(e)}),t(` removeEdgeLabelProxies`,function(){j(e)}),t(` normalize.run`,function(){i.run(e)}),t(` parentDummyChains`,function(){s(e)}),t(` addBorderSegments`,function(){u(e)}),t(` order`,function(){f(e)}),t(` insertSelfEdges`,function(){F(e)}),t(` adjustCoordinateSystem`,function(){d.adjust(e)}),t(` position`,function(){p(e)}),t(` positionSelfEdges`,function(){re(e)}),t(` removeBorderNodes`,function(){ne(e)}),t(` normalize.undo`,function(){i.undo(e)}),t(` fixupEdgeLabelCoords`,function(){N(e)}),t(` undoCoordinateSystem`,function(){d.undo(e)}),t(` translateGraph`,function(){ee(e)}),t(` assignNodeIntersects`,function(){M(e)}),t(` reversePoints`,function(){te(e)}),t(` acyclic.undo`,function(){r.undo(e)})}function v(e,t){n.forEach(e.nodes(),function(n){var r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,t.children(n).length&&(r.width=i.width,r.height=i.height))}),n.forEach(e.edges(),function(r){var i=e.edge(r),a=t.edge(r);i.points=a.points,n.has(a,`x`)&&(i.x=a.x,i.y=a.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var y=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],b={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},x=[`acyclicer`,`ranker`,`rankdir`,`align`],S=[`width`,`height`],C={width:0,height:0},w=[`minlen`,`weight`,`width`,`height`,`labeloffset`],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},E=[`labelpos`];function D(e){var t=new h({multigraph:!0,compound:!0}),r=L(e.graph());return t.setGraph(n.merge({},b,I(r,y),n.pick(r,x))),n.forEach(e.nodes(),function(r){var i=L(e.node(r));t.setNode(r,n.defaults(I(i,S),C)),t.setParent(r,e.parent(r))}),n.forEach(e.edges(),function(r){var i=L(e.edge(r));t.setEdge(r,n.merge({},T,I(i,w),n.pick(i,E)))}),t}function O(e){var t=e.graph();t.ranksep/=2,n.forEach(e.edges(),function(n){var r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function k(e){n.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),i={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};m.addDummyNode(e,`edge-proxy`,i,`_ep`)}})}function A(e){var t=0;n.forEach(e.nodes(),function(r){var i=e.node(r);i.borderTop&&(i.minRank=e.node(i.borderTop).rank,i.maxRank=e.node(i.borderBottom).rank,t=n.max(t,i.maxRank))}),e.graph().maxRank=t}function j(e){n.forEach(e.nodes(),function(t){var n=e.node(t);n.dummy===`edge-proxy`&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function ee(e){var t=1/0,r=0,i=1/0,a=0,o=e.graph(),s=o.marginx||0,c=o.marginy||0;function l(e){var n=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,n-s/2),r=Math.max(r,n+s/2),i=Math.min(i,o-c/2),a=Math.max(a,o+c/2)}n.forEach(e.nodes(),function(t){l(e.node(t))}),n.forEach(e.edges(),function(t){var r=e.edge(t);n.has(r,`x`)&&l(r)}),t-=s,i-=c,n.forEach(e.nodes(),function(n){var r=e.node(n);r.x-=t,r.y-=i}),n.forEach(e.edges(),function(r){var a=e.edge(r);n.forEach(a.points,function(e){e.x-=t,e.y-=i}),n.has(a,`x`)&&(a.x-=t),n.has(a,`y`)&&(a.y-=i)}),o.width=r-t+s,o.height=a-i+c}function M(e){n.forEach(e.edges(),function(t){var n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(m.intersectRect(r,a)),n.points.push(m.intersectRect(i,o))})}function N(e){n.forEach(e.edges(),function(t){var r=e.edge(t);if(n.has(r,`x`))switch((r.labelpos===`l`||r.labelpos===`r`)&&(r.width-=r.labeloffset),r.labelpos){case`l`:r.x-=r.width/2+r.labeloffset;break;case`r`:r.x+=r.width/2+r.labeloffset}})}function te(e){n.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}function ne(e){n.forEach(e.nodes(),function(t){if(e.children(t).length){var r=e.node(t),i=e.node(r.borderTop),a=e.node(r.borderBottom),o=e.node(n.last(r.borderLeft)),s=e.node(n.last(r.borderRight));r.width=Math.abs(s.x-o.x),r.height=Math.abs(a.y-i.y),r.x=o.x+r.width/2,r.y=i.y+r.height/2}}),n.forEach(e.nodes(),function(t){e.node(t).dummy===`border`&&e.removeNode(t)})}function P(e){n.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function F(e){var t=m.buildLayerMatrix(e);n.forEach(t,function(t){var r=0;n.forEach(t,function(t,i){var a=e.node(t);a.order=i+r,n.forEach(a.selfEdges,function(t){m.addDummyNode(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:a.rank,order:i+ ++r,e:t.e,label:t.label},`_se`)}),delete a.selfEdges})})}function re(e){n.forEach(e.nodes(),function(t){var n=e.node(t);if(n.dummy===`selfedge`){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function I(e,t){return n.mapValues(n.pick(e,t),Number)}function L(e){var t={};return n.forEach(e,function(e,n){t[n.toLowerCase()]=e}),t}})),Na=n(((e,t)=>{var n=G(),r=K(),i=W().Graph;t.exports={debugOrdering:a};function a(e){var t=r.buildLayerMatrix(e),a=new i({compound:!0,multigraph:!0}).setGraph({});return n.forEach(e.nodes(),function(t){a.setNode(t,{label:t}),a.setParent(t,`layer`+e.node(t).rank)}),n.forEach(e.edges(),function(e){a.setEdge(e.v,e.w,{},e.name)}),n.forEach(t,function(e,t){var r=`layer`+t;a.setNode(r,{rank:`same`}),n.reduce(e,function(e,t){return a.setEdge(e,t,{style:`invis`}),t})}),a}})),Pa=n(((e,t)=>{t.exports=`0.8.5`})),Fa=t(n(((e,t)=>{t.exports={graphlib:W(),layout:Ma(),debug:Na(),util:{time:K().time,notime:K().notime},version:Pa()}}))(),1);function Ia(e){let t=e.Transitions;return[...t.NextAction===void 0?[]:[t.NextAction],...(t.Errors??[]).map(e=>e.NextAction),...(t.Conditions??[]).map(e=>e.NextAction)]}function La(e){let t=new Fa.default.graphlib.Graph;t.setGraph({rankdir:`LR`,nodesep:40,ranksep:80,marginx:20,marginy:20}),t.setDefaultEdgeLabel(()=>({}));let n=new Set(e.map(e=>e.Identifier));for(let n of e)t.setNode(n.Identifier,{width:180,height:60});for(let r of e)for(let e of Ia(r))n.has(e)&&t.setEdge(r.Identifier,e);Fa.default.layout(t);let r={};for(let n of e){let e=t.node(n.Identifier);r[n.Identifier]=e?{x:Math.round(e.x-90),y:Math.round(e.y-30)}:{x:0,y:0}}return r}var Ra=`@flow-as-code`,za={core:`${Ra}/core`,cdk:`${Ra}/cdk`,cli:`${Ra}/cli`,tf:`${Ra}/tf`,studio:`${Ra}/studio`},Ba=za.core,Va=100;function Ha(e){return[`// Generated by ${za.core} codegen from ${e}.flowdoc.json.`,`// Edits to structure regenerate; comments marked @keep survive.`]}var Ua=class{code;constructor(e){this.code=e}},q=class{entries;constructor(e){this.entries=e}},Wa=class{items;constructor(e){this.items=e}};function Ga(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return new Wa(e.map(Ga));if(typeof e==`object`)return new q(Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,Ga(t)]));throw Error(`Cannot emit a ${typeof e} value.`)}var Ka=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function qa(e){let t=(e.match(/"/g)??[]).length>(e.match(/'/g)??[]).length?`'`:`"`,n=t;for(let r of e)r===`\\`?n+=`\\\\`:r===t?n+=`\\${t}`:r===`
2
+ `?n+=`\\n`:r===`\r`?n+=`\\r`:r===` `?n+=`\\t`:r<` `||r===`\u2028`||r===`\u2029`||r.codePointAt(0)>=55296&&r.codePointAt(0)<=57343?n+=`\\u${r.codePointAt(0).toString(16).padStart(4,`0`)}`:n+=r;return n+t}function Ja(e){return Ka.test(e)?e:qa(e)}function Ya(e){return e.items.length>1&&e.items.every(e=>e instanceof q&&e.entries.length>=2)}function Xa(e){if(e instanceof Ua)return e.code;if(typeof e==`string`)return qa(e);if(typeof e==`number`||typeof e==`boolean`||e===null)return String(e);if(e instanceof Wa){if(Ya(e))return;let t=e.items.map(Xa);return t.some(e=>e===void 0)?void 0:`[${t.join(`, `)}]`}if(e.entries.length===0)return`{}`;let t=e.entries.map(([e,t])=>{let n=Xa(t);return n===void 0?void 0:`${Ja(e)}: ${n}`});if(!t.some(e=>e===void 0))return`{ ${t.join(`, `)} }`}function Za(e,t,n){let r=Xa(e);if(r!==void 0&&t+r.length+1<=Va)return r;let i=`${n} `;return e instanceof q&&e.entries.length>0?Qa(e.entries,n):e instanceof Wa&&e.items.length>0?`[\n${e.items.map(e=>`${i}${Za(e,i.length,i)},`).join(`
3
+ `)}\n${n}]`:r??``}function Qa(e,t){let n=`${t} `;return`{\n${e.map(([e,t])=>{let r=`${n}${Ja(e)}: `;return`${r}${Za(t,r.length,n)},`}).join(`
4
+ `)}\n${t}}`}function $a(e){return Array.isArray(e)?`[${e.map($a).join(`,`)}]`:typeof e==`object`&&e?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${$a(e[t])}`).join(`,`)}}`:JSON.stringify(e)}var J=e=>e;function eo(e,t,n){if(typeof e!=`string`)return;let r=O(e);if(r!==void 0)return r.type===t?t===`module`?r.alias===void 0?void 0:(n.refs=!0,new Ua(`Refs.module(${qa(r.name)}, ${qa(r.alias)})`)):r.alias===void 0?(n.refs=!0,new Ua(`Refs.${t}(${qa(r.name)})`)):void 0:void 0;if(/^\$\.[A-Za-z0-9_$.[\]'-]+$/.test(e))return n.jsonPath=!0,new Ua(`jsonPath(${qa(e)})`)}function to(e,t,n=[]){let r=Object.keys(e);return t.every(e=>r.includes(e))&&r.every(e=>t.includes(e)||n.includes(e))}function no(e,t){if(e.NextAction===void 0)return;let n=e.Errors??[];if(n.length===1&&n[0].ErrorType===t&&(e.Conditions??[]).length===0)return{next:e.NextAction,onError:n[0].NextAction}}function ro(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&Object.values(e).every(e=>typeof e==`string`)}var io=[`Equals`,`TextStartsWith`,`TextEndsWith`,`TextContains`,`NumberGreaterThan`,`NumberGreaterOrEqualTo`,`NumberLessThan`,`NumberLessOrEqualTo`];function ao(e){let t=e;return typeof t.NextAction==`string`&&typeof t.Condition==`object`&&t.Condition!==null&&typeof t.Condition.Operator==`string`&&io.includes(t.Condition.Operator)&&Array.isArray(t.Condition.Operands)&&t.Condition.Operands.every(e=>typeof e==`string`)}function oo(e,t){if(Object.keys(e.Parameters).length===0&&Object.keys(e.Transitions).length===0)return{cls:e.Type,entries:[[`id`,e.Identifier]],block:t()}}var so={[A.MessageParticipant]:(e,t)=>{let n=no(e.Transitions,M);if(n===void 0)return;let r=e.Parameters,i=Object.keys(r);if(i.length!==1)return;let a=[[`id`,e.Identifier]];if(i[0]===`Text`&&typeof r.Text==`string`)a.push([`text`,r.Text]);else if(i[0]===`SSML`&&typeof r.SSML==`string`)a.push([`ssml`,r.SSML]);else if(i[0]===`PromptId`){let e=eo(r.PromptId,j[A.MessageParticipant].PromptId,t);if(e===void 0)return;a.push([`prompt`,e])}else return;a.push([`next`,n.next],[`onError`,n.onError]);let o=i[0]===`Text`?{text:J(r.Text)}:i[0]===`SSML`?{ssml:J(r.SSML)}:{prompt:J(r.PromptId)};return{cls:`MessageParticipant`,entries:a,block:new se({id:e.Identifier,...o,next:n.next,onError:n.onError})}},[A.GetParticipantInput]:(e,t)=>{let n=e.Transitions,r=n.Errors??[],i=[te,N,M];if(r.length!==i.length||r.some((e,t)=>e.ErrorType!==i[t]))return;let[a,o,s]=r.map(e=>e.NextAction);if(n.NextAction!==o)return;let c=n.Conditions??[];if(!c.every(ao))return;let l=[];for(let e of c){if(e.Condition.Operator!==`Equals`||e.Condition.Operands.length!==1)return;let t=e.Condition.Operands[0];if(!ae.includes(t))return;l.push({digit:t,target:e.NextAction})}let u=e.Parameters;if(!to(u,[`InputTimeLimitSeconds`,`StoreInput`],[`Text`,`SSML`,`PromptId`])||u.StoreInput!==`False`||typeof u.InputTimeLimitSeconds!=`string`||!/^[1-9][0-9]*$/.test(u.InputTimeLimitSeconds))return;let d=Number(u.InputTimeLimitSeconds),f=[`Text`,`SSML`,`PromptId`].filter(e=>e in u);if(f.length>1)return;let p=[[`id`,e.Identifier]],m={};if(f[0]===`Text`&&typeof u.Text==`string`)p.push([`text`,u.Text]),m={text:u.Text};else if(f[0]===`SSML`&&typeof u.SSML==`string`)p.push([`ssml`,u.SSML]),m={ssml:u.SSML};else if(f[0]===`PromptId`){let e=eo(u.PromptId,j[A.GetParticipantInput].PromptId,t);if(e===void 0)return;p.push([`prompt`,e]),m={prompt:J(u.PromptId)}}else if(f.length===1)return;return p.push([`timeoutSeconds`,d],[`branches`,new Wa(l.map(e=>new q([[`digit`,e.digit],[`target`,e.target]])))],[`onTimeout`,a],[`onNoMatch`,o],[`onError`,s]),{cls:`GetParticipantInput`,entries:p,block:new ce({id:e.Identifier,...m,timeoutSeconds:d,branches:l,onTimeout:a,onNoMatch:o,onError:s})}},[A.DisconnectParticipant]:e=>oo(e,()=>new le({id:e.Identifier})),[A.EndFlowExecution]:e=>oo(e,()=>new B({id:e.Identifier})),[A.EndFlowModuleExecution]:e=>oo(e,()=>new ve({id:e.Identifier})),[A.CheckHoursOfOperation]:(e,t)=>{let n=e.Transitions,r=n.Errors??[],i=n.Conditions??[];if(r.length!==1||r[0].ErrorType!==`NoMatchingError`||i.length!==2)return;let[a,o]=i;if($a(a.Condition)!==$a({Operator:`Equals`,Operands:[`True`]})||$a(o.Condition)!==$a({Operator:`Equals`,Operands:[`False`]})||n.NextAction!==o.NextAction||!to(e.Parameters,[],[`HoursOfOperationId`]))return;let s=[[`id`,e.Identifier]],c;if(`HoursOfOperationId`in e.Parameters){let n=eo(e.Parameters.HoursOfOperationId,`hours`,t);if(n===void 0)return;s.push([`hours`,n]),c=J(e.Parameters.HoursOfOperationId)}return s.push([`onInHours`,a.NextAction],[`onOutOfHours`,o.NextAction],[`onError`,r[0].NextAction]),{cls:`CheckHoursOfOperation`,entries:s,block:new ue({id:e.Identifier,...c===void 0?{}:{hours:J(c)},onInHours:a.NextAction,onOutOfHours:o.NextAction,onError:r[0].NextAction})}},[A.Compare]:(e,t)=>{let n=e.Transitions;if(n.NextAction!==void 0)return;let r=n.Errors??[];if(r.length!==1||r[0].ErrorType!==`NoMatchingCondition`)return;let i=n.Conditions??[];if(i.length===0||!i.every(ao)||!to(e.Parameters,[`ComparisonValue`]))return;let a=e.Parameters.ComparisonValue;if(typeof a!=`string`||!/^\$\.[A-Za-z0-9_$.[\]'-]+$/.test(a))return;t.jsonPath=!0;let o=i.map(e=>({operator:e.Condition.Operator,operands:e.Condition.Operands,target:e.NextAction}));return{cls:`Compare`,entries:[[`id`,e.Identifier],[`value`,new Ua(`jsonPath(${qa(a)})`)],[`branches`,new Wa(o.map(e=>new q([[`operator`,e.operator],[`operands`,new Wa([...e.operands])],[`target`,e.target]])))],[`onNoMatch`,r[0].NextAction]],block:new de({id:e.Identifier,value:J(a),branches:o,onNoMatch:r[0].NextAction})}},[A.TransferToFlow]:(e,t)=>{let n=no(e.Transitions,M);if(n===void 0||!to(e.Parameters,[`ContactFlowId`]))return;let r=eo(e.Parameters.ContactFlowId,`flow`,t);if(r!==void 0)return{cls:`TransferToFlow`,entries:[[`id`,e.Identifier],[`flow`,r],[`next`,n.next],[`onError`,n.onError]],block:new fe({id:e.Identifier,flow:J(e.Parameters.ContactFlowId),next:n.next,onError:n.onError})}},[A.UpdateContactTargetQueue]:(e,t)=>{let n=no(e.Transitions,M);if(n===void 0)return;let r=Object.keys(e.Parameters);if(r.length!==1||r[0]!==`QueueId`&&r[0]!==`AgentId`)return;let i=r[0],a=eo(e.Parameters[i],`queue`,t);if(a===void 0)return;let o=i===`QueueId`?`queue`:`agent`;return{cls:`UpdateContactTargetQueue`,entries:[[`id`,e.Identifier],[o,a],[`next`,n.next],[`onError`,n.onError]],block:new pe(J({id:e.Identifier,[o]:e.Parameters[i],next:n.next,onError:n.onError}))}},[A.TransferContactToQueue]:e=>{let t=e.Transitions;if(Object.keys(e.Parameters).length!==0||t.NextAction===void 0||(t.Conditions??[]).length!==0)return;let n=t.Errors??[];if(n.length===2&&n[0].ErrorType===`QueueAtCapacity`&&n[1].ErrorType===`NoMatchingError`)return{cls:`TransferContactToQueue`,entries:[[`id`,e.Identifier],[`next`,t.NextAction],[`onQueueAtCapacity`,n[0].NextAction],[`onError`,n[1].NextAction]],block:new me({id:e.Identifier,next:t.NextAction,onQueueAtCapacity:n[0].NextAction,onError:n[1].NextAction})}},[A.UpdateContactAttributes]:e=>{let t=no(e.Transitions,M);if(t===void 0||!to(e.Parameters,[`Attributes`,`TargetContact`]))return;let n=e.Parameters.Attributes,r=e.Parameters.TargetContact;if(!ro(n)||r!==`Current`&&r!==`Related`)return;let i=[[`id`,e.Identifier],[`attributes`,Ga(n)]];return r===`Related`&&i.push([`targetContact`,`Related`]),i.push([`next`,t.next],[`onError`,t.onError]),{cls:`UpdateContactAttributes`,entries:i,block:new he({id:e.Identifier,attributes:n,...r===`Related`?{targetContact:r}:{},next:t.next,onError:t.onError})}},[A.UpdateContactRecordingBehavior]:e=>{let t=no(e.Transitions,M);if(t===void 0||!to(e.Parameters,[`RecordingBehavior`]))return;let n=e.Parameters.RecordingBehavior;if(typeof n!=`object`||!n||Array.isArray(n)||!to(n,[`RecordedParticipants`],[`ScreenRecordedParticipants`,`IVRRecordingBehavior`]))return;let r=n.RecordedParticipants;if(!Array.isArray(r)||!r.every(e=>e===`Agent`||e===`Customer`))return;let i=[[`id`,e.Identifier],[`recordedParticipants`,new Wa([...r])]],a=n.ScreenRecordedParticipants;if(a!==void 0){if(!Array.isArray(a)||!a.every(e=>e===`Agent`))return;i.push([`screenRecordedParticipants`,new Wa([...a])])}let o=n.IVRRecordingBehavior;if(o!==void 0){if(o!==`Enabled`&&o!==`Disabled`)return;i.push([`ivrRecordingBehavior`,o])}return i.push([`next`,t.next],[`onError`,t.onError]),{cls:`UpdateContactRecordingBehavior`,entries:i,block:new ge({id:e.Identifier,recordedParticipants:J(r),...a===void 0?{}:{screenRecordedParticipants:J(a)},...o===void 0?{}:{ivrRecordingBehavior:o},next:t.next,onError:t.onError})}},[A.InvokeFlowModule]:(e,t)=>{let n=no(e.Transitions,M);if(n===void 0||!to(e.Parameters,[`FlowModuleId`]))return;let r=eo(e.Parameters.FlowModuleId,`module`,t);if(r!==void 0)return{cls:`InvokeFlowModule`,entries:[[`id`,e.Identifier],[`module`,r],[`next`,n.next],[`onError`,n.onError]],block:new _e({id:e.Identifier,module:J(e.Parameters.FlowModuleId),next:n.next,onError:n.onError})}},[A.InvokeLambdaFunction]:(e,t)=>{let n=no(e.Transitions,M);if(n===void 0)return;let r=e.Parameters;if(!to(r,[`LambdaFunctionARN`,`InvocationTimeLimitSeconds`,`InvocationType`],[`LambdaInvocationAttributes`,`ResponseValidation`]))return;let i=eo(r.LambdaFunctionARN,`lambda`,t);if(i===void 0)return;let a=r.InvocationTimeLimitSeconds;if(typeof a!=`number`)return;let o=r.InvocationType;if(o!==`SYNCHRONOUS`&&o!==`ASYNCHRONOUS`)return;let s=[[`id`,e.Identifier],[`lambda`,i],[`timeoutSeconds`,a]];o===`ASYNCHRONOUS`&&s.push([`invocationType`,o]);let c=r.LambdaInvocationAttributes;if(c!==void 0){if(!ro(c))return;s.push([`attributes`,Ga(c)])}let l;if(r.ResponseValidation!==void 0){let e=r.ResponseValidation;if(typeof e!=`object`||!e||!to(e,[`ResponseType`])||e.ResponseType!==`STRING_MAP`&&e.ResponseType!==`JSON`)return;l=e.ResponseType,s.push([`responseType`,l])}return s.push([`next`,n.next],[`onError`,n.onError]),{cls:`InvokeLambdaFunction`,entries:s,block:new ye({id:e.Identifier,lambda:J(r.LambdaFunctionARN),timeoutSeconds:a,...o===`ASYNCHRONOUS`?{invocationType:o}:{},...c===void 0?{}:{attributes:J(c)},...l===void 0?{}:{responseType:l},next:n.next,onError:n.onError})}}};function co(e){let t=[[`id`,e.Identifier],[`type`,e.Type]],n={id:e.Identifier,type:e.Type},r=e.Parameters??{};Object.keys(r).length>0&&(t.push([`parameters`,Ga(r)]),n.parameters=r);let i=e.Transitions??{};i.NextAction!==void 0&&(t.push([`next`,i.NextAction]),n.next=i.NextAction);let a=i.Errors??[];a.length>0&&(t.push([`errors`,new Wa(a.map(e=>new q([[`errorType`,e.ErrorType],[`target`,e.NextAction]])))]),n.errors=a.map(e=>({errorType:e.ErrorType,target:e.NextAction})));let o=i.Conditions??[];return o.length>0&&(t.push([`conditions`,new Wa(o.map(e=>new q([[`target`,e.NextAction],[`operator`,e.Condition.Operator],[`operands`,new Wa([...e.Condition.Operands])]])))]),n.conditions=o.map(e=>({target:e.NextAction,operator:e.Condition.Operator,operands:e.Condition.Operands}))),{cls:`GenericBlock`,entries:t,block:new be(n)}}function lo(e,t){let n=so[e.Type];if(n!==void 0)try{let r={refs:!1,jsonPath:!1},i=n(e,r);if(i!==void 0&&$a(i.block.toAction())===$a(e))return t.refs=t.refs||r.refs,t.jsonPath=t.jsonPath||r.jsonPath,i}catch{}return co(e)}var uo=/^new [A-Za-z_$][A-Za-z0-9_$]*\(\{/,fo=/\bid: (["'])((?:[^"'\\]|\\.)*)\1/;function po(e){let t={beforeExport:[],beforeBlock:new Map},n=e.split(`
5
+ `),r=[];for(let e=0;e<n.length;e++){let i=n[e].trim();if(i.startsWith(`//`)){r.push(i);continue}let a=r.filter(e=>e.includes(`@keep`));if(r=[],a.length!==0){if(i.startsWith(`export function `))t.beforeExport=a;else if(uo.test(i))for(let r=e;r<Math.min(e+5,n.length);r++){let e=fo.exec(n[r]);if(e!==null){t.beforeBlock.set(e[2],a);break}}}}return t}var mo=new Set(`await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield`.split(`.`));function ho(e,t=new Set){let n=e.split(/[^A-Za-z0-9]+/).filter(e=>e.length>0);if(n.length===0)throw Error(`Cannot derive a factory name from flow name "${e}".`);let r=n.map((e,t)=>t===0?e:e[0].toUpperCase()+e.slice(1)).join(``);for(;/^[0-9]/.test(r)||mo.has(r)||t.has(r);)r=`flow${r[0].toUpperCase()}${r.slice(1)}`;return r}function go(e){let t=[[`name`,e.name]];e.kind!==`module`&&t.push([`connectType`,e.connectType]);let n=e.content.Settings;e.kind===`module`&&n!==void 0&&Object.keys(n).length>0&&t.push([`settings`,Ga(n)]);let r=e.content.Actions[0];if(r!==void 0&&e.content.StartAction!==r.Identifier&&t.push([`start`,e.content.StartAction]),e.layout!==void 0){let n=La(e.content.Actions);if($a(e.layout)!==$a(n)){let n=Object.keys(e.layout).sort().map(t=>{let n=e.layout[t];return[t,new q([[`x`,n.x],[`y`,n.y]])]});t.push([`layout`,new q(n)])}}return t}function _o(e,t){let n=`new ${e.cls}(`;if(e.entries.length===1){let r=Xa(new q(e.entries));if(r!==void 0&&t.length+n.length+r.length+2<=Va)return`${n}${r})`}return`${n}${Qa(e.entries,t)})`}function vo(e){if(e.entries.length!==1)return;let t=Xa(new q(e.entries));return t===void 0?void 0:`new ${e.cls}(${t})`}function yo(e,t={}){if(T(e,`codegen`),e.kind===`module`&&e.connectType!==`MODULE`)throw Error(`FlowDoc kind "module" requires connectType MODULE, got ${e.connectType}.`);if(e.content.Actions.length===0)throw Error(`Flow "${e.name}" has no actions; nothing to generate.`);let n=t.moduleSpecifier??Ba,r=t.previous===void 0?{beforeExport:[],beforeBlock:new Map}:po(t.previous),i={refs:!1,jsonPath:!1},a=e.content.Actions.map(e=>lo(e,i)),o=e.kind===`module`?`FlowModule`:`Flow`,s=new Set([o,...a.map(e=>e.cls)]);i.refs&&s.add(`Refs`),i.jsonPath&&s.add(`jsonPath`);let c=[...s].sort(),l=`import { ${c.join(`, `)} } from ${qa(n)};`,u=l.length<=Va?l:`import {\n${c.map(e=>` ${e},`).join(`
6
+ `)}\n} from ${qa(n)};`,d=ho(e.name,s),f=go(e),p=Xa(new q(f)),m=a.map(vo),h=a.some(e=>r.beforeBlock.has(e.block.id)),g,_=p===void 0||m.some(e=>e===void 0)?void 0:` return new ${o}(${p}).add(${m.join(`, `)});`;if(_!==void 0&&_.length<=Va&&!h)g=_;else{let e=p===void 0?void 0:` return new ${o}(${p}).add(`,t=e!==void 0&&e.length<=Va?e:` return new ${o}(${Qa(f,` `)}).add(`,n=[];for(let e of a){for(let t of r.beforeBlock.get(e.block.id)??[])n.push(` ${t}`);n.push(` ${_o(e,` `)},`)}g=`${t}\n${n.join(`
7
+ `)}\n );`}let v=[...Ha(e.name),``,u,``];for(let e of r.beforeExport)v.push(e);return v.push(`export function ${d}(): ${o} {`,g,`}`),v.join(`
8
+ `)+`
9
+ `}function bo(e){if(Array.isArray(e))return e.map(bo);if(typeof e!=`object`||!e)return e;let t=Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t));return Object.fromEntries(t.map(([e,t])=>[e,bo(t)]))}function xo(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);for(let r of Object.keys(e).sort())!t.includes(r)&&e[r]!==void 0&&(n[r]=e[r]);return n}function So(e){let t={...e};return e.Errors!==void 0&&(t.Errors=e.Errors.map(e=>xo({...e},[`ErrorType`,`NextAction`]))),e.Conditions!==void 0&&(t.Conditions=e.Conditions.map(e=>xo({NextAction:e.NextAction,Condition:xo({...e.Condition},[`Operator`,`Operands`])},[`NextAction`,`Condition`]))),xo(t,[`NextAction`,`Errors`,`Conditions`])}function Co(e){return{Identifier:e.Identifier,Type:e.Type,Parameters:bo(e.Parameters),Transitions:So(e.Transitions)}}function wo(e){let t={flowdoc:e.flowdoc,kind:e.kind,name:e.name,connectType:e.connectType,content:xo({Version:e.content.Version,StartAction:e.content.StartAction,...e.content.Settings===void 0?{}:{Settings:bo(e.content.Settings)},...e.content.Metadata===void 0?{}:{Metadata:bo(e.content.Metadata)},Actions:e.content.Actions.map(Co)},[`Version`,`StartAction`,`Settings`,`Metadata`,`Actions`])};return e.layout!==void 0&&(t.layout=bo(e.layout)),e.refs!==void 0&&(t.refs=e.refs.map(e=>xo({...e},[`token`,`type`,`name`,`alias`]))),e.meta!==void 0&&(t.meta=bo(e.meta)),t}function To(e){return JSON.stringify(wo(e),null,2)+`
10
+ `}var Eo=class extends Error{missingTokens;constructor(e,t){super(t===void 0?`Cannot materialize: ${String(e.length)} unmapped token(s): `+e.join(`, `):`Cannot materialize: ${t} Offending token(s): ${e.join(`, `)}`),this.name=`MaterializeError`,this.missingTokens=e}};function Do(e,t){if(typeof e==`string`){let n=O(e);return n===void 0?e:t(n)}return Array.isArray(e)?e.map(e=>Do(e,t)):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Do(n,t)])):e}var Oo=100;function ko(e,t){let n=e.content.Actions,r=e.layout??{},i=n.some(e=>r[e.Identifier]===void 0)?La(n):{},a=Do(e.content.Metadata??{},t),o=a.ActionMetadata,s={...typeof o==`object`&&o&&!Array.isArray(o)?o:{}},c={};for(let e of n){let t=r[e.Identifier]??i[e.Identifier]??{x:0,y:0};c[e.Identifier]=t;let n=s[e.Identifier],a=typeof n==`object`&&n&&!Array.isArray(n)?n:{};s[e.Identifier]={...a,Position:{x:t.x,y:t.y}}}let l=c[e.content.StartAction]??{x:0,y:0},u={x:Math.max(l.x-Oo,0),y:l.y};return{...a,EntryPointPosition:u,ActionMetadata:s}}function Ao(e,t){let n=e.kind===`module`||e.content.Settings!==void 0?Do(e.content.Settings??{},t):void 0;return{Version:e.content.Version,StartAction:e.content.StartAction,...n===void 0?{}:{Settings:n},Metadata:ko(e,t),Actions:e.content.Actions.map(e=>Do(e,t))}}function jo(e,t){if(T(e,`materializeWithMap`),typeof t!=`object`||!t||Array.isArray(t))throw new S(`materializeWithMap expects a token to value map object as its second argument.`);let n=k(e.content).map(e=>e.token).filter(e=>!Object.hasOwn(t,e));if(n.length>0)throw new Eo(n);let r=Ao(e,e=>t[e.token]),i=[...new Set(JSON.stringify(r).match(/\$\{cdref:[^}"]*\}/g)??[])].sort();if(i.length>0)throw new Eo(i,`Token(s) survived materialization because they are embedded in a longer string. A reference must be the entire field value (FlowDoc invariant 4).`);return r}function Mo(e){let t=xo({Version:e.Version,StartAction:e.StartAction,...e.Settings===void 0?{}:{Settings:bo(e.Settings)},...e.Metadata===void 0?{}:{Metadata:xo(bo(e.Metadata),[`EntryPointPosition`,`ActionMetadata`])},Actions:e.Actions.map(Co)},[`Version`,`StartAction`,`Settings`,`Metadata`,`Actions`]);return JSON.stringify(t,null,2)+`
11
+ `}var No=`(?:[0-9]*|aws)`;new RegExp(String.raw`^arn:aws[a-z0-9-]*:[a-z0-9-]*:[a-z0-9-]*:${No}:\S+$`),new RegExp(String.raw`arn:aws[a-z0-9-]*:[a-z0-9-]*:[a-z0-9-]*:${No}:[^\s"']+`,`g`);var Po={id:`action-allowed-in-flow-type`,description:`Each action must be legal in the flow type that contains it.`,check({doc:e,report:t}){for(let n of e.content.Actions){let r=ie[n.Type];r!==void 0&&(r.includes(e.connectType)||t({severity:`error`,blockId:n.Identifier,message:`${n.Type} is not allowed in a ${e.connectType} flow. Allowed: ${r.join(`, `)}.`}))}}},Fo={id:`action-count`,description:`A flow holds no more than 250 actions.`,check({doc:e,report:t}){let n=e.content.Actions.length;n>250&&t({severity:`error`,message:`Flow has ${String(n)} actions; Connect allows at most 250.`})}};function Io(e){let t=e.Transitions;return[...t.NextAction===void 0?[]:[t.NextAction],...(t.Errors??[]).map(e=>e.NextAction),...(t.Conditions??[]).map(e=>e.NextAction)]}function Lo(e){return Object.keys(e.Transitions).length===0}function Ro(e){return new Map(e.content.Actions.map(e=>[e.Identifier,e]))}function zo(e){let t=Ro(e),n=new Set,r=[e.content.StartAction];for(;r.length>0;){let e=r.shift();if(n.has(e))continue;let i=t.get(e);i!==void 0&&(n.add(e),r.push(...Io(i)))}return n}function Bo(e,t=``){return typeof e==`string`?[[t,e]]:Array.isArray(e)?e.flatMap((e,n)=>Bo(e,`${t}[${n}]`)):typeof e==`object`&&e?Object.entries(e).flatMap(([e,n])=>Bo(n,t===``?e:`${t}.${e}`)):[]}function Vo(e){return e.content.Metadata===void 0?[]:Bo(e.content.Metadata,`content.Metadata`)}function Ho(e){return e.content.Actions.map(e=>({action:e,strings:[...Bo(e.Parameters),...Bo(e.Transitions,`Transitions`)]}))}var Uo=new Set(Object.values(A)),Wo={id:`error-branches`,description:`Every non-terminal modeled action must wire its catch-all error branch.`,check({doc:e,report:t}){for(let n of e.content.Actions){if(Lo(n)||!Uo.has(n.Type)||ee.includes(n.Type))continue;let e=n.Type===A.Compare?N:M;(n.Transitions.Errors??[]).some(t=>t.ErrorType===e)||t({severity:`error`,blockId:n.Identifier,message:`${n.Type} does not wire its "${e}" branch.`})}}};function Go(e){let t=[];for(let n of e.content.Actions){if(n.Type!==A.InvokeFlowModule)continue;let e=n.Parameters.FlowModuleId;if(typeof e!=`string`)continue;let r=O(e);r?.type===`module`&&t.push(r.name)}return t}var Ko={id:`module-depth-5`,description:`Flow module invocation must not nest more than five levels deep, and must not recurse.`,check({doc:e,all:t,report:n}){if(e.kind!==`flow`)return;let r=new Map(t.filter(e=>e.kind===`module`).map(e=>[e.name,e])),i=(e,t,a)=>{for(let o of Go(e)){if(a.includes(o)){n({severity:`error`,message:`Recursive module invocation: ${[...a,o].join(` -> `)}.`});continue}if(t+1>5){n({severity:`error`,message:`Module nesting reaches depth ${t+1} via ${[...a,o].join(` -> `)}; Connect allows 5.`});continue}let e=r.get(o);e!==void 0&&i(e,t+1,[...a,o])}};i(e,0,[e.name])}},qo=/arn:aws[a-z-]*:/,Jo=`no-literal-arn`;function Yo(e){return`"${e}" contains a literal ARN. Use a \${cdref:type:name} token instead.`}var Xo={id:Jo,description:"Authored content must not contain a literal ARN; use a ${cdref:...} token.",hard:!0,check({doc:e,report:t}){let n=[...Vo(e),...Bo(e.refs??[],`refs`)];for(let[e,r]of n)qo.test(r)&&t({severity:`error`,message:Yo(e)});for(let{action:n,strings:r}of Ho(e))for(let[e,i]of r)qo.test(i)&&t({severity:`error`,blockId:n.Identifier,message:`${e.startsWith(`Transitions`)?`Transition`:`Parameter`} ${Yo(e)}`})}},Zo=/\$\{\s*cdref[^}]*\}/gi,Qo={id:`no-unresolved-token`,description:"Every ${cdref:...} token must be well formed, stand alone, and appear in the refs index.",hard:!0,check({doc:e,report:t}){let n=new Set((e.refs??[]).map(e=>e.token)),r=[...Vo(e).map(([e,t])=>({path:e,value:t})),...Ho(e).flatMap(({action:e,strings:t})=>t.map(([t,n])=>({blockId:e.Identifier,path:t,value:n})))],i=e=>e.startsWith(`content.Metadata`)?``:e.startsWith(`Transitions`)?`Transition `:`Parameter `;for(let{blockId:e,path:a,value:o}of r){let r=o.match(Zo)??[];if(r.length===0)continue;if(!E.test(o)){t({severity:`error`,...e===void 0?{}:{blockId:e},message:`${i(a)}"${a}" embeds a token in a larger string ("${o}"). A token must be the entire value.`});continue}let s=r[0];O(s)===void 0?t({severity:`error`,...e===void 0?{}:{blockId:e},message:`${i(a)}"${a}" contains a malformed token "${s}".`}):n.has(s)||t({severity:`error`,...e===void 0?{}:{blockId:e},message:`Token "${s}" is missing from the refs index. Re-run synth to regenerate it.`})}}},$o=3e3,es=6e3,ts=[A.MessageParticipant,A.GetParticipantInput],ns=e=>e.replace(/<[^>]*>/g,``),rs={id:`prompt-length-3000`,description:`Prompt text must stay within 3,000 billed characters and 6,000 total.`,check({doc:e,report:t}){for(let n of e.content.Actions){if(!ts.includes(n.Type))continue;let e=n.Parameters.Text;typeof e==`string`&&e.length>3e3&&t({severity:`error`,blockId:n.Identifier,message:`Text is ${e.length} characters; Connect allows ${$o} billed characters.`});let r=n.Parameters.SSML;if(typeof r==`string`){r.length>6e3&&t({severity:`error`,blockId:n.Identifier,message:`SSML is ${r.length} characters; Connect allows ${es} total.`});let e=ns(r).length;e>3e3&&t({severity:`error`,blockId:n.Identifier,message:`SSML contains ${e} spoken characters; Connect allows ${$o} billed characters.`})}}}},is={id:`reachable-blocks`,description:`Every action should be reachable from StartAction, and every transition target must exist.`,check({doc:e,report:t}){let n=Ro(e);n.has(e.content.StartAction)||t({severity:`error`,message:`StartAction "${e.content.StartAction}" does not match any action.`});for(let r of e.content.Actions)for(let e of Io(r))n.has(e)||t({severity:`error`,blockId:r.Identifier,message:`Transition points at "${e}", which does not exist.`});let r=zo(e);for(let n of e.content.Actions)r.has(n.Identifier)||t({severity:`warning`,blockId:n.Identifier,message:`Action is not reachable from StartAction.`})}};function as(e){if(e.Type!==A.UpdateContactRecordingBehavior)return!1;let t=e.Parameters.RecordingBehavior;if(typeof t!=`object`||!t)return!1;let n=t.RecordedParticipants;return Array.isArray(n)&&n.length>0}var os=[`Text`,`SSML`,`PromptId`];function ss(e){return e.Type!==A.MessageParticipant&&e.Type!==A.GetParticipantInput?!1:os.some(t=>{let n=e.Parameters[t];return typeof n==`string`&&n.trim()!==``})}function cs(e,t){let n=Ro(e),r=new Set,i=[e.content.StartAction];for(;i.length>0;){let e=i.shift();if(e===t)return!0;if(r.has(e))continue;r.add(e);let a=n.get(e);a!==void 0&&(ss(a)||i.push(...Io(a)))}return!1}var ls=[Xo,Qo,is,Wo,{id:`terminal-blocks`,description:`A flow must reach a terminal action, and only terminal action types may have empty transitions.`,check({doc:e,report:t}){let n=Ro(e);[...zo(e)].some(e=>{let t=n.get(e);return t!==void 0&&Lo(t)&&ee.includes(t.Type)})||t({severity:`error`,message:`No terminal action is reachable from StartAction; the flow cannot end.`});for(let n of e.content.Actions)Lo(n)&&!ee.includes(n.Type)&&t({severity:`warning`,blockId:n.Identifier,message:`${n.Type} has no transitions but is not a terminal action type, so the flow dead-ends here.`})}},Ko,rs,{id:`recording-consent-before-record`,description:`Recording must not start before the participant has been played a message.`,check({doc:e,report:t}){for(let n of e.content.Actions)as(n)&&cs(e,n.Identifier)&&t({severity:`error`,blockId:n.Identifier,message:`Recording is enabled on a path that plays no message first. Announce recording before starting it.`})}},{id:`unique-names`,description:`Action Identifiers are unique within a flow, document names unique within a set, and both are valid.`,check({doc:e,all:t,report:n}){let r=new Set;for(let t of e.content.Actions)r.has(t.Identifier)&&n({severity:`error`,blockId:t.Identifier,message:`Duplicate Identifier "${t.Identifier}".`}),r.add(t.Identifier),x(t.Identifier)||n({severity:`error`,blockId:t.Identifier,message:`Identifier "${t.Identifier}" is not valid: at most 50 characters, and none of % : ( \\ / ) = $ , ; [ ] { }.`});t.filter(t=>t.name===e.name).length>1&&n({severity:`error`,message:`Duplicate document name "${e.name}" in this flow set.`})}},Po,Fo],us=(e,t)=>e.doc.localeCompare(t.doc)||e.rule.localeCompare(t.rule)||(e.blockId??``).localeCompare(t.blockId??``)||e.message.localeCompare(t.message);function ds(e,t={}){let n=Array.isArray(e)?e:[e];for(let e of n)T(e,`lint`);let r=new Set(t.disable??[]),i=(t.rules??ls).filter(e=>!r.has(e.id)),a=[];for(let e of n)for(let t of i)t.check({doc:e,all:n,report:n=>a.push({...n,rule:t.id,doc:e.name})});return a.sort(us)}function fs(e,t=ls){let n=new Set(t.filter(e=>e.hard).map(e=>e.id));return e.some(e=>n.has(e.rule))}var ps=`new GenericBlock(`,ms={n:`
12
+ `,r:`\r`,t:` `,"\\":`\\`,'"':`"`,"'":`'`};function hs(e,t){let n=e[t];if(n!==`"`&&n!==`'`)return;let r=``;for(let i=t+1;i<e.length;i++){let t=e[i];if(t===`\\`){let t=e[i+1];if(t===void 0)return;if(t===`u`){let t=e.slice(i+2,i+6);if(!/^[0-9a-fA-F]{4}$/.test(t))return;r+=String.fromCharCode(parseInt(t,16)),i+=5;continue}let n=ms[t];if(n===void 0)return;r+=n,i+=1;continue}if(t===n)return{value:r,end:i+1};r+=t}}function gs(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;return n}function _s(e,t){let n=gs(e,t);if(e[n]===`{`&&(n=gs(e,n+1),e.startsWith(`id`,n)&&(n=gs(e,n+2),e[n]===`:`)))return n=gs(e,n+1),hs(e,n)?.value}function vs(e){let t=new Set,n=0;for(;n<e.length;){let r=e[n];if(r===`"`||r===`'`){let t=hs(e,n);if(t===void 0)throw Error(`Generated source has an unterminated string literal.`);n=t.end;continue}if(r===`/`&&e[n+1]===`/`){let t=e.indexOf(`
13
+ `,n);n=t<0?e.length:t+1;continue}if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t<0?e.length:t+2;continue}if(r===`n`&&e.startsWith(ps,n)){let r=_s(e,n+17);if(r===void 0)throw Error(`Cannot read the id of a GenericBlock in generated source; codegen's output shape changed.`);t.add(r),n+=17;continue}n++}return t}function ys(e){let t=e.indexOf(`import {`);if(t<0)throw Error(`Generated source has no import statement.`);let n=e.indexOf(`;`,t);if(n<0)throw Error(`Generated source has an unterminated import statement.`);return/(^|[\s,{])GenericBlock([\s,}]|$)/.test(e.slice(t,n))}var bs=new WeakMap;function xs(e){let t=bs.get(e);if(t!==void 0)return t;let n;try{let{layout:t,...r}=e,i=yo(r),a=vs(i);if(ys(i)!==a.size>0)throw Error(`Generated source imports ${ys(i)?``:`no `}GenericBlock but ${String(a.size)} were parsed.`);let o=new Set(e.content.Actions.map(e=>e.Identifier));for(let e of a)if(!o.has(e))throw Error(`Parsed GenericBlock id "${e}" is not an Action in this document.`);n={generated:!0,ids:a}}catch(e){n={generated:!1,error:e instanceof Error?e.message:String(e)}}return bs.set(e,n),n}function Ss(e){let t=xs(e);return t.generated?t.ids:new Set}function Cs(e,t){let n=xs(e),r=xs(t);if(!n.generated)return{demoted:[],unverifiable:n.error??`the document could not be analysed`};if(!r.generated)return{demoted:[],ungeneratable:r.error??`the change made the document ungeneratable`};let i=new Set(e.content.Actions.map(e=>e.Identifier));return{demoted:[...r.ids].filter(e=>i.has(e)&&!n.ids.has(e)).sort()}}var ws={[A.MessageParticipant]:`Interact`,[A.GetParticipantInput]:`Interact`,[A.UpdateContactTargetQueue]:`Set`,[A.UpdateContactAttributes]:`Set`,[A.UpdateContactRecordingBehavior]:`Set`,[A.CheckHoursOfOperation]:`Branch`,[A.Compare]:`Branch`,[A.InvokeLambdaFunction]:`Integrate`,[A.InvokeFlowModule]:`Integrate`,[A.TransferToFlow]:`Terminate`,[A.TransferContactToQueue]:`Terminate`,[A.DisconnectParticipant]:`Terminate`,[A.EndFlowExecution]:`Terminate`,[A.EndFlowModuleExecution]:`Terminate`},Ts=[`Interact`,`Set`,`Branch`,`Integrate`,`Terminate`].map(e=>({category:e,types:Object.keys(ws).filter(t=>ws[t]===e)}));function Es(e){return e in ws}function Ds(e){return ws[e]}var Os={[A.MessageParticipant]:`message`,[A.GetParticipantInput]:`menu`,[A.DisconnectParticipant]:`disconnect`,[A.CheckHoursOfOperation]:`check-hours`,[A.Compare]:`compare`,[A.TransferToFlow]:`transfer-to-flow`,[A.EndFlowExecution]:`end-flow`,[A.TransferContactToQueue]:`transfer-to-queue`,[A.UpdateContactTargetQueue]:`set-queue`,[A.UpdateContactAttributes]:`set-attributes`,[A.UpdateContactRecordingBehavior]:`set-recording`,[A.InvokeFlowModule]:`invoke-module`,[A.EndFlowModuleExecution]:`end-module`,[A.InvokeLambdaFunction]:`invoke-lambda`};function ks(e){switch(e){case A.MessageParticipant:return{Text:`New message`};case A.GetParticipantInput:return{Text:`New menu`,InputTimeLimitSeconds:`5`,StoreInput:`False`};case A.Compare:return{ComparisonValue:`$.Attributes.value`};case A.UpdateContactAttributes:return{Attributes:{},TargetContact:`Current`};case A.UpdateContactRecordingBehavior:return{RecordingBehavior:{RecordedParticipants:[`Agent`,`Customer`]}};case A.InvokeLambdaFunction:return{InvocationTimeLimitSeconds:8,InvocationType:`SYNCHRONOUS`,ResponseValidation:{ResponseType:`STRING_MAP`}};default:return{}}}function As(e,t){return{Identifier:t,Type:e,Parameters:ks(e),Transitions:{}}}function js(e){return`${e}:next`}function Ms(e,t,n){return`${e}:error:${t}:${n}`}function Ns(e,t){return`${e}:condition:${t}`}function Ps(e){let t=e.indexOf(`:`);if(t<0)return;let n=e.slice(0,t),r=e.slice(t+1);if(r===`next`)return{source:n,kind:`next`};if(r.startsWith(`error:`)){let e=r.slice(6),t=e.indexOf(`:`);if(t<0)return;let i=Number(e.slice(0,t));return Number.isInteger(i)&&i>=0?{source:n,kind:`error`,errorIndex:i,errorType:e.slice(t+1)}:void 0}if(r.startsWith(`condition:`)){let e=Number(r.slice(10));if(Number.isInteger(e)&&e>=0)return{source:n,kind:`condition`,conditionIndex:e}}}function Fs(e,t){let n=t.map(e=>String(e)).join(`, `);return`${e} ${n.length>24?`${n.slice(0,24)}…`:n}`}function Is(e){let t=e.layout??{},n=e.content.Actions.some(e=>t[e.Identifier]===void 0)?La(e.content.Actions):{},r={};for(let i of e.content.Actions)r[i.Identifier]=t[i.Identifier]??n[i.Identifier]??{x:0,y:0};return r}function Ls(e){let t=new Set(e.content.Actions.map(e=>e.Identifier)),n=[];for(let r of e.content.Actions){let e=r.Transitions,i=r.Identifier;e.NextAction!==void 0&&!t.has(e.NextAction)&&n.push({source:i,kind:`next`,target:e.NextAction,label:`next`}),(e.Errors??[]).forEach((e,r)=>{t.has(e.NextAction)||n.push({source:i,kind:`error`,target:e.NextAction,label:e.ErrorType,errorIndex:r})}),(e.Conditions??[]).forEach((e,r)=>{t.has(e.NextAction)||n.push({source:i,kind:`condition`,target:e.NextAction,label:Fs(e.Condition.Operator,e.Condition.Operands),conditionIndex:r})})}return n}function Rs(e){let t=Is(e),n=new Set(e.content.Actions.map(e=>e.Identifier)),r=e.content.Actions.map(n=>({id:n.Identifier,position:t[n.Identifier]??{x:0,y:0},action:n,category:Es(n.Type)?Ds(n.Type):`generic`,isGeneric:!Es(n.Type),isStart:n.Identifier===e.content.StartAction})),i=[];for(let t of e.content.Actions){let e=t.Transitions,r=t.Identifier;e.NextAction!==void 0&&n.has(e.NextAction)&&i.push({id:js(r),source:r,target:e.NextAction,kind:`next`}),(e.Errors??[]).forEach((e,t)=>{n.has(e.NextAction)&&i.push({id:Ms(r,t,e.ErrorType),source:r,target:e.NextAction,kind:`error`,label:e.ErrorType,errorType:e.ErrorType,errorIndex:t})}),(e.Conditions??[]).forEach((e,t)=>{n.has(e.NextAction)&&i.push({id:Ns(r,t),source:r,target:e.NextAction,kind:`condition`,label:Fs(e.Condition.Operator,e.Condition.Operands),conditionIndex:t})})}return{nodes:r,edges:i,dangling:Ls(e)}}function zs(e){return ee.includes(e)}function Bs(e){return e.Type===A.GetParticipantInput&&e.Parameters.StoreInput!==`True`}function Vs(e){return!zs(e.Type)&&e.Type!==A.Compare&&!Bs(e)}function Hs(e){return zs(e.Type)?!1:e.Type===A.Compare?!0:e.Type===A.GetParticipantInput?Bs(e):!Es(e.Type)&&(e.Transitions.Conditions??[]).length>0}var Us=[`Equals`,`TextStartsWith`,`TextEndsWith`,`TextContains`,`NumberGreaterThan`,`NumberGreaterOrEqualTo`,`NumberLessThan`,`NumberLessOrEqualTo`];function Ws(e){return Us.includes(e)}function Gs(e){let t=e.split(`,`).map(e=>e.trim()).filter(e=>e!==``);return t.length===0?[``]:t}var Ks=`Equals`,qs=Gs(``),Js=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`0`,`*`,`#`];function Ys(e){let t=new Set;for(let n of e.Transitions.Conditions??[])for(let e of n.Condition.Operands)t.add(String(e));return t}function Xs(e){if(e.Type!==A.GetParticipantInput)return{Operator:Ks,Operands:[...qs]};let t=Ys(e),n=Js.find(e=>!t.has(e));return n===void 0?void 0:{Operator:`Equals`,Operands:[n]}}var Zs=class extends Error{mutation;blockIds;constructor(e,t,n){super(n),this.name=`MutationRefused`,this.mutation=e,this.blockIds=t}},Qs=Symbol.for(`flow-studio.guarded-mutation`);function $s(e){return typeof e==`object`&&!!e&&typeof e.flowdoc==`string`&&typeof e.content==`object`}function ec(e,t){if(t!==void 0){if($s(t))return t;if(typeof t==`object`&&t){let e=t.doc;if($s(e))return e;if(t.ok===!1)return}throw TypeError(`${e}: a guarded mutation must return a FlowDoc, { doc }, { ok: false }, or undefined.`)}}function tc(e,t){let n=t.map(e=>`"${e}"`).join(`, `),r=t.length>1;return`${e.label} would turn ${n} into ${r?`read-only generic blocks`:`a read-only generic block`}: the code generator could no longer express ${r?`them`:`it`} as ${r?`typed blocks`:`a typed block`}. ${e.hint}`}function nc(e,t,n){let r=(r,...i)=>{if(!$s(r))throw TypeError(`${e}: the first argument of a guarded mutation must be a FlowDoc.`);let a=n(r,...i),o=ec(e,a);if(o===void 0||o===r)return a;let s=Cs(r,o);if(s.unverifiable!==void 0)throw new Zs(e,[],`${t.label} cannot be checked because this document could not be analysed: ${s.unverifiable}`);if(s.ungeneratable!==void 0)throw new Zs(e,[],`${t.label} would leave the flow in a state the code generator cannot emit at all: ${s.ungeneratable}`);if(s.demoted.length>0)throw new Zs(e,s.demoted,tc(t,s.demoted));return a};return Object.defineProperty(r,"name",{value:e}),Object.defineProperty(r,Qs,{value:e,enumerable:!1}),r}function rc(e){return wo({...e,refs:k(e.content)})}function ic(e,t,n){return{...e,content:{...e.content,Actions:e.content.Actions.map(e=>e.Identifier===t?n(e):e)}}}function ac(e,t){return e.content.Actions.find(e=>e.Identifier===t)}function oc(e,t){let n=0;for(let r of e.content.Actions){if(r.Identifier===t)continue;let e=r.Transitions;e.NextAction===t&&n++,n+=(e.Errors??[]).filter(e=>e.NextAction===t).length,n+=(e.Conditions??[]).filter(e=>e.NextAction===t).length}return n}function sc(e,t){let n=Os[t],r=new Set(e.content.Actions.map(e=>e.Identifier));if(!r.has(n))return n;for(let e=2;;e++){let t=`${n}-${e}`;if(!r.has(t))return t}}function cc(e){return e.content.Actions.length<250}var lc=[`Text`,`SSML`,`PromptId`];function uc(e){return lc.find(t=>e.Parameters[t]!==void 0)}var dc=nc(`moveNode`,{label:`Moving that block`,hint:`This should be impossible; please report it.`},(e,t,n)=>ac(e,t)===void 0?e:rc({...e,layout:{...e.layout,[t]:{x:Math.round(n.x),y:Math.round(n.y)}}}));function fc(e,t,n,r,i={}){return rc(ic(e,t,e=>{let t={...e.Parameters};for(let e of i.clears??[])delete t[e];return r===void 0?delete t[n]:t[n]=r,{...e,Parameters:t}}))}var pc=nc(`setParam`,{label:`That parameter change`,hint:`Give the parameter a value the block type accepts instead of clearing it.`},fc),mc=nc(`setNumberParam`,{label:`That parameter change`,hint:`Give the parameter a value the block type accepts instead.`},(e,t,n,r,i={})=>{let a=typeof r==`string`?r.trim():r;if(a===``||a==null)return{ok:!1,error:`Enter a number.`};let o=Number(a);return Number.isFinite(o)?i.integer!==!1&&!Number.isInteger(o)?{ok:!1,error:`Must be a whole number.`}:i.min!==void 0&&o<i.min?{ok:!1,error:`Must be at least ${i.min}.`}:i.max!==void 0&&o>i.max?{ok:!1,error:`Must be at most ${i.max}.`}:{ok:!0,doc:fc(e,t,n,i.asString===!0?String(o):o)}:{ok:!1,error:`"${String(r)}" is not a number.`}}),hc=nc(`setMessageBody`,{label:`That message body change`,hint:"Give PromptId a ${cdref:prompt:...} reference or a JSONPath; Text and SSML take any string."},(e,t,n,r)=>{if(typeof r!=`string`)throw TypeError(`setMessageBody: ${n} must be a string; a message cannot be left with no body.`);return fc(e,t,n,r,{clears:lc.filter(e=>e!==n)})}),gc=nc(`addBlock`,{label:`Adding that block`,hint:`This should be impossible; please report it.`},(e,t,n)=>{if(!cc(e))throw Error(`This flow already has 250 actions; Connect allows no more.`);let r=sc(e,t);return{doc:rc({...e,content:{...e.content,Actions:[...e.content.Actions,As(t,r)]},layout:{...e.layout,[r]:{x:Math.round(n.x),y:Math.round(n.y)}}}),id:r}}),_c=nc(`deleteBlock`,{label:`Deleting that block`,hint:`Rewire the transitions that point at it to another block first, then delete it.`},(e,t)=>{if(e.content.StartAction===t)throw Error(`Cannot delete "${t}": it is the flow's StartAction.`);let n={...e.layout};return delete n[t],rc({...e,content:{...e.content,Actions:e.content.Actions.filter(e=>e.Identifier!==t).map(e=>{let n={...e.Transitions};return n.NextAction===t&&delete n.NextAction,n.Errors!==void 0&&(n.Errors=n.Errors.filter(e=>e.NextAction!==t)),n.Conditions!==void 0&&(n.Conditions=n.Conditions.filter(e=>e.NextAction!==t)),{...e,Transitions:n}})},layout:n})});function vc(e){let t=yc(e);return t===void 0||e.Transitions.NextAction===t?e:{...e,Transitions:{...e.Transitions,NextAction:t}}}function yc(e){if(e.Type===A.GetParticipantInput)return(e.Transitions.Errors??[]).find(e=>e.ErrorType===N)?.NextAction}function bc(e,t,n){let r=Xs(t);if(r!==void 0)return rc(ic(e,t.Identifier,e=>({...e,Transitions:{...e.Transitions,Conditions:[...e.Transitions.Conditions??[],{NextAction:n,Condition:r}]}})))}function xc(e,t,n){if(!Es(t.Type)||t.Type===A.GetParticipantInput&&!Bs(t))return;let r=t.Type===A.Compare?N:M,i=[...ne[t.Type]??[],r],a=new Set((t.Transitions.Errors??[]).map(e=>e.ErrorType)),o=i.find(e=>!a.has(e));if(o!==void 0)return rc(ic(e,t.Identifier,e=>vc({...e,Transitions:{...e.Transitions,Errors:[...e.Transitions.Errors??[],{ErrorType:o,NextAction:n}]}})))}var Sc=nc(`connectNodes`,{label:`Wiring that transition`,hint:`That block cannot carry this transition; wire it from a different handle or block.`},(e,t,n,r)=>{let i=ac(e,t);if(i!==void 0&&ac(e,n)!==void 0&&!zs(i.Type)){if(r!==`error`){if(Hs(i)){let t=bc(e,i,n);if(t!==void 0)return t}else if(Vs(i)&&i.Transitions.NextAction===void 0)return rc(ic(e,t,e=>({...e,Transitions:{...e.Transitions,NextAction:n}})));if(r===`primary`)return}return xc(e,i,n)}}),Cc=nc(`setCondition`,{label:`That branch change`,hint:`Restore an operator and operands the block type accepts.`},(e,t,n,r)=>{let i=ac(e,t);if(i!==void 0&&(i.Transitions.Conditions??[])[n]!==void 0&&Ws(r.Operator)&&!(r.Operands.length===0||r.Operands.length>10))return rc(ic(e,t,e=>({...e,Transitions:{...e.Transitions,Conditions:(e.Transitions.Conditions??[]).map((e,t)=>t===n?{...e,Condition:{...r,Operands:[...r.Operands]}}:e)}})))}),wc=nc(`removeCondition`,{label:`Removing that branch`,hint:`Wire a replacement branch before removing the last one, or delete the block instead.`},(e,t,n)=>{let r=ac(e,t);if(r!==void 0&&(r.Transitions.Conditions??[])[n]!==void 0)return rc(ic(e,t,e=>({...e,Transitions:{...e.Transitions,Conditions:(e.Transitions.Conditions??[]).filter((e,t)=>t!==n)}})))});function Tc(e,t){return ic(e,t.source,e=>{let n={...e.Transitions};if(t.kind===`next`){let t=n.NextAction;delete n.NextAction,t!==void 0&&yc(e)===t&&(n.Errors=(n.Errors??[]).filter(e=>e.ErrorType!==N))}if(t.kind===`error`){let r=(n.Errors??[])[t.errorIndex];n.Errors=(n.Errors??[]).filter((e,n)=>n!==t.errorIndex),e.Type===A.GetParticipantInput&&r?.ErrorType===`NoMatchingCondition`&&n.NextAction===r.NextAction&&delete n.NextAction}return t.kind===`condition`&&(n.Conditions=(n.Conditions??[]).filter((e,n)=>n!==t.conditionIndex)),{...e,Transitions:n}})}var Ec=nc(`rewireEdge`,{label:`Rewiring that transition`,hint:`That block cannot carry this transition; drop the edge on a different block.`},(e,t,n,r)=>{let i=Ps(t);if(i===void 0)return;let a=ac(e,i.source),o=ac(e,n);if(a!==void 0&&o!==void 0&&ac(e,r)!==void 0){if(n===i.source)return rc(ic(e,n,e=>{let t={...e.Transitions};return i.kind===`next`&&(t.NextAction=r,e.Type===A.GetParticipantInput&&(t.Errors=(t.Errors??[]).map(e=>e.ErrorType===`NoMatchingCondition`?{...e,NextAction:r}:e))),i.kind===`error`&&(t.Errors=(t.Errors??[]).map((e,t)=>t===i.errorIndex?{...e,NextAction:r}:e)),i.kind===`condition`&&(t.Conditions=(t.Conditions??[]).map((e,t)=>t===i.conditionIndex?{...e,NextAction:r}:e)),vc({...e,Transitions:t})}));if(i.kind===`next`){if(o.Transitions.NextAction!==void 0)return;let e=yc(o);if(e!==void 0&&e!==r)return}if(i.kind===`error`&&i.errorType===`NoMatchingCondition`&&o.Type===A.GetParticipantInput){if(!Bs(o)||yc(o)!==void 0)return;let e=o.Transitions.NextAction;if(e!==void 0&&e!==r)return}return rc(ic(Tc(e,i),n,e=>{let t={...e.Transitions};if(i.kind===`next`&&(t.NextAction=r),i.kind===`error`&&(t.Errors=[...t.Errors??[],{ErrorType:i.errorType,NextAction:r}]),i.kind===`condition`){let n=(a.Transitions.Conditions??[])[i.conditionIndex];if(n===void 0)return e;t.Conditions=[...t.Conditions??[],{...n,NextAction:r}]}return vc({...e,Transitions:t})}))}});function Dc(e){let t=e.split(/[/\\]/).pop();return t===void 0||t===``?e:t}function Oc(e,t){let n=Dc(e);return`Code out of sync: ${n}: ${(t.split(`
14
+ `)[0]??``).trim().split(e).join(n)}`}var kc=h(),Ac={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:`https://flow-as-code.dev/schema/flowdoc-0.1.schema.json`,title:`FlowDoc 0.1`,description:`Interchange format for Amazon Connect flows. See docs/01-flowdoc-spec.md and conformance/flow-language/actions.md. This schema is part of the cross-language contract: the future Go provider validates against it.`,type:`object`,required:[`flowdoc`,`kind`,`name`,`connectType`,`content`],additionalProperties:!1,properties:{flowdoc:{const:`0.1`},kind:{enum:[`flow`,`module`]},name:{type:`string`,minLength:1,pattern:`^[a-z0-9]+(-[a-z0-9]+)*$`},connectType:{enum:[`CONTACT_FLOW`,`CUSTOMER_QUEUE`,`CUSTOMER_HOLD`,`CUSTOMER_WHISPER`,`AGENT_HOLD`,`AGENT_WHISPER`,`OUTBOUND_WHISPER`,`AGENT_TRANSFER`,`QUEUE_TRANSFER`,`MODULE`]},content:{$ref:`#/$defs/flowContent`},layout:{description:`Canvas positions keyed by Action Identifier. Projected into content.Metadata.ActionMetadata at materialization; never stored in content.`,type:`object`,additionalProperties:{$ref:`#/$defs/point`}},refs:{description:`Derived index of every token in content. Regenerated on save.`,type:`array`,items:{$ref:`#/$defs/ref`}},meta:{type:`object`,properties:{generator:{type:`string`},sourceHash:{type:`string`,pattern:`^sha256:[0-9a-f]{64}$`}},additionalProperties:!0}},$defs:{point:{type:`object`,required:[`x`,`y`],additionalProperties:!1,properties:{x:{type:`number`},y:{type:`number`}}},token:{description:`A reference token. Occupies the entire field value; never interpolated into a longer string, because Connect requires these fields to be fully static or a single JSONPath identifier.`,type:`string`,pattern:`^\\$\\{cdref:(queue|hours|lambda|lex|prompt|flow|module):[a-z0-9]+(-[a-z0-9]+)*(@[a-z0-9]+(-[a-z0-9]+)*)?\\}$`},ref:{type:`object`,required:[`token`,`type`,`name`],additionalProperties:!1,properties:{token:{$ref:`#/$defs/token`},type:{enum:[`queue`,`hours`,`lambda`,`lex`,`prompt`,`flow`,`module`]},name:{type:`string`,pattern:`^[a-z0-9]+(-[a-z0-9]+)*$`},alias:{type:`string`,pattern:`^[a-z0-9]+(-[a-z0-9]+)*$`}}},identifier:{description:`Unique within the flow, up to 50 chars. Connect forbids % : ( \\ / ) = $ , ; [ ] { } and a set of prototype-pollution names.`,type:`string`,minLength:1,maxLength:50,pattern:`^[^%:(\\\\/)=$,;\\[\\]{}]+$`,not:{enum:[`__proto__`,`constructor`,`__defineGetter__`,`__defineSetter__`,`toString`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`valueOf`]}},flowContent:{type:`object`,required:[`Version`,`StartAction`,`Actions`],additionalProperties:!1,properties:{Version:{const:`2019-10-30`},StartAction:{$ref:`#/$defs/identifier`},Metadata:{description:"Not authored in FlowDoc. Materialization writes positions here from `layout`.",type:`object`},Actions:{type:`array`,minItems:1,maxItems:250,items:{$ref:`#/$defs/action`}},Settings:{type:`object`,description:`Module configuration. Required (may be empty) in a module's content; absent in a flow's.`}}},action:{type:`object`,required:[`Identifier`,`Type`,`Parameters`,`Transitions`],additionalProperties:!1,properties:{Identifier:{$ref:`#/$defs/identifier`},Type:{type:`string`,minLength:1},Parameters:{type:`object`},Transitions:{$ref:`#/$defs/transitions`}},allOf:[{if:{properties:{Type:{const:`UpdateContactTargetQueue`}},required:[`Type`]},then:{properties:{Parameters:{properties:{QueueId:{$ref:`#/$defs/refField`},AgentId:{$ref:`#/$defs/refField`}}}}}},{if:{properties:{Type:{const:`CheckHoursOfOperation`}},required:[`Type`]},then:{properties:{Parameters:{properties:{HoursOfOperationId:{$ref:`#/$defs/refField`}}}}}},{if:{properties:{Type:{const:`InvokeLambdaFunction`}},required:[`Type`]},then:{properties:{Parameters:{properties:{LambdaFunctionARN:{$ref:`#/$defs/refField`}}}}}},{if:{properties:{Type:{const:`InvokeFlowModule`}},required:[`Type`]},then:{properties:{Parameters:{properties:{FlowModuleId:{$ref:`#/$defs/refField`}}}}}},{if:{properties:{Type:{const:`TransferToFlow`}},required:[`Type`]},then:{properties:{Parameters:{properties:{ContactFlowId:{$ref:`#/$defs/refField`}}}}}},{if:{properties:{Type:{const:`MessageParticipant`}},required:[`Type`]},then:{properties:{Parameters:{properties:{PromptId:{$ref:`#/$defs/refField`}}}}}},{if:{properties:{Type:{const:`UpdateContactTargetQueue`}},required:[`Type`]},then:{properties:{Parameters:{not:{required:[`QueueId`,`AgentId`]}}}}},{if:{properties:{Type:{const:`MessageParticipant`}},required:[`Type`]},then:{properties:{Parameters:{oneOf:[{required:[`PromptId`],not:{anyOf:[{required:[`Text`]},{required:[`SSML`]}]}},{required:[`Text`],not:{anyOf:[{required:[`PromptId`]},{required:[`SSML`]}]}},{required:[`SSML`],not:{anyOf:[{required:[`PromptId`]},{required:[`Text`]}]}}]}}}},{if:{properties:{Type:{const:`InvokeLambdaFunction`}},required:[`Type`]},then:{properties:{Parameters:{properties:{InvocationTimeLimitSeconds:{type:`integer`,minimum:1,maximum:8},InvocationType:{enum:[`SYNCHRONOUS`,`ASYNCHRONOUS`]}}}}}},{if:{properties:{Type:{const:`GetParticipantInput`}},required:[`Type`]},then:{properties:{Parameters:{properties:{PromptId:{$ref:`#/$defs/refField`},StoreInput:{enum:[`True`,`False`]},InputTimeLimitSeconds:{oneOf:[{type:`integer`,minimum:1},{type:`string`,pattern:`^[1-9][0-9]*$`}]}},not:{anyOf:[{required:[`PromptId`,`Text`]},{required:[`PromptId`,`SSML`]},{required:[`Text`,`SSML`]}]}}}}}]},transitions:{type:`object`,additionalProperties:!1,properties:{NextAction:{$ref:`#/$defs/identifier`},Errors:{type:`array`,items:{type:`object`,required:[`ErrorType`,`NextAction`],additionalProperties:!1,properties:{ErrorType:{type:`string`,minLength:1},NextAction:{$ref:`#/$defs/identifier`}}}},Conditions:{type:`array`,items:{type:`object`,required:[`NextAction`,`Condition`],additionalProperties:!1,properties:{NextAction:{$ref:`#/$defs/identifier`},Condition:{$ref:`#/$defs/condition`}}}}}},condition:{type:`object`,required:[`Operator`,`Operands`],additionalProperties:!1,properties:{Operator:{enum:[`Equals`,`TextStartsWith`,`TextEndsWith`,`TextContains`,`NumberGreaterThan`,`NumberGreaterOrEqualTo`,`NumberLessThan`,`NumberLessOrEqualTo`]},Operands:{type:`array`,minItems:1,maxItems:10}}},jsonPath:{description:`A single JSONPath identifier, e.g. $.Attributes.queueId`,type:`string`,pattern:`^\\$\\.[A-Za-z0-9_$.\\[\\]'-]+$`},refField:{description:`A reference-bearing parameter: either a cdref token or a single JSONPath identifier. Never a literal ARN.`,oneOf:[{$ref:`#/$defs/token`},{$ref:`#/$defs/jsonPath`}]}},allOf:[{if:{properties:{kind:{const:`module`}},required:[`kind`]},then:{properties:{connectType:{const:`MODULE`}}},else:{properties:{connectType:{not:{const:`MODULE`}}}}}]},jc=ls.filter(e=>e.hard===!0).map(e=>e.id),Mc=new Set(jc),Nc=new kc.Ajv2020({allErrors:!0,strict:!1}).compile(Ac);function Pc(e){return`${e.instancePath===``?`(root)`:e.instancePath} ${e.message??`is invalid`}`}function Fc(e){return Nc(e)?[]:(Nc.errors??[]).map(Pc)}function Ic(e){let t=Fc(e),n=ds(e),r=fs(n)?n.filter(e=>Mc.has(e.rule)):[];return{ok:t.length===0&&r.length===0,schemaErrors:t,blockers:r}}var Lc=class extends Error{validation;constructor(e){let t=[...e.blockers.map(e=>`${e.rule}: ${e.message}`),...e.schemaErrors.map(e=>`schema: ${e}`)];super(`Refusing to write an invalid FlowDoc. ${t.join(`; `)}`),this.name=`SaveRefusedError`,this.validation=e}};function Rc(e){let t=Ic(e);if(!t.ok)throw new Lc(t)}function zc(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`Not JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let n=t;if(typeof n!=`object`||!n||n.flowdoc!==`0.1`)throw Error(`Not a FlowDoc 0.1 file.`);if(!Nc(n)){let e=(Nc.errors??[]).map(Pc).slice(0,5).join(`; `);throw Error(`Not a valid FlowDoc 0.1: ${e}`)}return n}var Bc=`/bridge`,Vc=`__FLOW_STUDIO_BRIDGE__`,Hc=`x-flow-studio-token`,Uc=`.flowdoc.json`,Wc=`.flow.ts`,Gc=/^[A-Za-z0-9_][A-Za-z0-9._-]*$/;function Kc(e,t){if(e===``||e.length>200||e.includes(`\0`)||e.includes(`\\`))return;let n=e.split(`/`);if(!(n.length>t))return n.every(e=>Gc.test(e))?n:void 0}function qc(e){return e===``||Kc(e,3)!==void 0}function Jc(e){return`${e}${Bc}/docs`}function Yc(e,t){return`${Jc(e)}/${encodeURIComponent(t)}`}function Xc(e,t){return`${Yc(e,t)}/resolve`}function Zc(e,t){return`${e}${Bc}/events?cursor=${String(t)}`}function Qc(e){return`${e}${Bc}/export`}function $c(e){if(typeof e!=`object`||!e)return;let t=e[Vc];if(typeof t!=`object`||!t)return;let n=t;if(n.protocol===1&&typeof n.token==`string`&&n.token!==``&&typeof n.dir==`string`&&typeof n.label==`string`)return{protocol:n.protocol,dir:n.dir,label:n.label,token:n.token}}var el=class extends Error{conflict;constructor(e,t){super(t),this.name=`BridgeConflictError`,this.conflict=e}};function tl(){if(typeof fetch!=`function`)throw Error(`This environment has no fetch; the studio bridge needs one.`);return(e,t)=>fetch(e,t)}var nl=class{persistent=!0;readOnly=!1;label;info;base;fetch;retryMs;idleMs;constructor(e,t={}){this.info=e,this.label=e.label,this.base=t.base??``,this.fetch=t.fetch??tl(),this.retryMs=t.retryMs??1e3,this.idleMs=t.idleMs??25}async request(e,t){let n=await this.fetch(e,{...t,headers:{...t?.headers??{},[Hc]:this.info.token}}),r=await n.text();if(!n.ok)throw this.failure(n.status,r);try{return JSON.parse(r)}catch{throw Error(`The studio bridge answered ${e} with something that is not JSON.`)}}failure(e,t){let n;try{n=JSON.parse(t)}catch{n=void 0}let r=n?.error??`The studio bridge answered ${String(e)}.`;return e===409&&n?.conflict!==void 0?new el(n.conflict,r):Error(r)}async list(){return(await this.request(Jc(this.base))).docs.map(e=>({name:e.name}))}async read(e){let t=await this.request(Yc(this.base,e));return{doc:zc(t.text),text:t.text}}async write(e,t,n={}){Rc(t),await this.request(Yc(this.base,e),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(n.force===!0?{doc:t,force:!0}:{doc:t})})}async postExport(e){return this.request(Qc(this.base),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}async resolve(e,t){let n=await this.request(Xc(this.base,e),{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({side:t})});return{...n,doc:zc(n.text)}}subscribe(e,t){let n=new AbortController,r=0;return(async()=>{for(;!n.signal.aborted;)try{let t=await this.request(Zc(this.base,r),{signal:n.signal});r=t.cursor;for(let r of t.events){if(n.signal.aborted)return;e(r)}t.events.length===0&&await this.pause(this.idleMs,n.signal)}catch(e){if(n.signal.aborted)return;t?.(e instanceof Error?e.message:String(e)),await this.pause(this.retryMs,n.signal)}})(),()=>n.abort()}pause(e,t){return new Promise(n=>{let r=setTimeout(()=>{t.removeEventListener(`abort`,i),n()},e),i=()=>{clearTimeout(r),n()};t.addEventListener(`abort`,i,{once:!0})})}};function rl(e=globalThis){return $c(e)}function il(e=globalThis,t={}){let n=rl(e);return n===void 0?void 0:new nl(n,t)}var al={flowdoc:`0.1`,kind:`flow`,name:`appointment-line`,connectType:`CONTACT_FLOW`,content:{Version:`2019-10-30`,StartAction:`enable-logging`,Actions:[{Identifier:`enable-logging`,Type:`UpdateFlowLoggingBehavior`,Parameters:{FlowLoggingBehavior:`Enabled`},Transitions:{NextAction:`welcome`,Errors:[],Conditions:[]}},{Identifier:`welcome`,Type:`MessageParticipant`,Parameters:{Text:`Thanks for calling. Let's get you to the right place.`},Transitions:{NextAction:`check-hours`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`apologize`}],Conditions:[]}},{Identifier:`check-hours`,Type:`CheckHoursOfOperation`,Parameters:{HoursOfOperationId:"${cdref:hours:main-line}"},Transitions:{NextAction:`announce-closed`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`apologize`}],Conditions:[{NextAction:`set-working-queue`,Condition:{Operator:`Equals`,Operands:[`True`]}},{NextAction:`announce-closed`,Condition:{Operator:`Equals`,Operands:[`False`]}}]}},{Identifier:`set-working-queue`,Type:`UpdateContactTargetQueue`,Parameters:{QueueId:"${cdref:queue:appointments}"},Transitions:{NextAction:`look-up-appointment`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`apologize`}],Conditions:[]}},{Identifier:`look-up-appointment`,Type:`InvokeLambdaFunction`,Parameters:{InvocationTimeLimitSeconds:8,InvocationType:`SYNCHRONOUS`,LambdaFunctionARN:"${cdref:lambda:appointment-lookup}",ResponseValidation:{ResponseType:`STRING_MAP`}},Transitions:{NextAction:`record-lookup-result`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`transfer`}],Conditions:[]}},{Identifier:`record-lookup-result`,Type:`UpdateContactAttributes`,Parameters:{Attributes:{appointmentFound:`$.External.appointmentFound`},TargetContact:`Current`},Transitions:{NextAction:`transfer`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`transfer`}],Conditions:[]}},{Identifier:`transfer`,Type:`TransferContactToQueue`,Parameters:{},Transitions:{NextAction:`hang-up`,Errors:[{ErrorType:`QueueAtCapacity`,NextAction:`announce-busy`},{ErrorType:`NoMatchingError`,NextAction:`apologize`}],Conditions:[]}},{Identifier:`announce-closed`,Type:`MessageParticipant`,Parameters:{Text:`We are closed right now. Please call back during business hours.`},Transitions:{NextAction:`hang-up`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`hang-up`}],Conditions:[]}},{Identifier:`announce-busy`,Type:`MessageParticipant`,Parameters:{Text:`All of our lines are busy. Please try again shortly.`},Transitions:{NextAction:`hang-up`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`hang-up`}],Conditions:[]}},{Identifier:`apologize`,Type:`MessageParticipant`,Parameters:{Text:`Something went wrong on our end. Please try again later.`},Transitions:{NextAction:`hang-up`,Errors:[{ErrorType:`NoMatchingError`,NextAction:`hang-up`}],Conditions:[]}},{Identifier:`hang-up`,Type:`DisconnectParticipant`,Parameters:{},Transitions:{}}]},layout:{"announce-busy":{x:1840,y:150},"announce-closed":{x:1840,y:20},apologize:{x:1840,y:250},"check-hours":{x:540,y:50},"enable-logging":{x:20,y:170},"hang-up":{x:2100,y:110},"look-up-appointment":{x:1060,y:140},"record-lookup-result":{x:1320,y:100},"set-working-queue":{x:800,y:180},transfer:{x:1580,y:140},welcome:{x:280,y:170}},refs:[{token:"${cdref:hours:main-line}",type:`hours`,name:`main-line`},{token:"${cdref:lambda:appointment-lookup}",type:`lambda`,name:`appointment-lookup`},{token:"${cdref:queue:appointments}",type:`queue`,name:`appointments`}]},ol=class{label;persistent=!1;readOnly=!1;texts=new Map;constructor(e,t){this.label=e;for(let e of t)this.texts.set(e.name,To(e))}list(){return Promise.resolve([...this.texts.keys()].sort().map(e=>({name:e})))}read(e){let t=this.texts.get(e);return t===void 0?Promise.reject(Error(`No document named "${e}".`)):Promise.resolve({doc:JSON.parse(t),text:t})}write(e,t){try{Rc(t)}catch(e){return Promise.reject(e instanceof Error?e:Error(String(e)))}return this.texts.set(e,To(t)),Promise.resolve()}};function sl(){return structuredClone(al)}function cl(){return new ol(`demo`,[sl()])}var ll=`This is a read-only demo: edits stay in this tab and are not saved. Reload the page to restore the demo flow.`,ul=class{inner;persistent=!1;readOnly=!0;label;constructor(e){this.inner=e,this.label=e.label}list(){return this.inner.list()}read(e){return this.inner.read(e)}write(e,t){return Promise.reject(Error(ll))}};function dl(e){return new ul(e)}var Y=a();function fl(e,t){return e===null?!1:e.name===void 0||e.name===t}var pl=`This document changed on both sides, so editing is paused. Choose which version wins; the dialog is showing the two it can write.`;function ml(e){return{store:e,docList:[],docName:null,doc:null,dirty:!1,findings:[],blocked:!1,lintPending:!1,selected:null,rawFor:null,focus:null,notice:null,conflict:null,resolving:!1,syncError:null,error:null}}function hl(e,t){switch(t.type){case`store-opened`:return{...ml(t.store),docList:t.docList};case`doc-loaded`:return{...e,docName:t.name,doc:t.doc,dirty:!1,findings:[],blocked:!1,lintPending:!0,selected:null,rawFor:null,focus:null,notice:null,conflict:null,resolving:!1,error:null};case`doc-synced`:{let n=fl(e.syncError,t.name)?null:e.syncError;if(t.name!==e.docName)return n===e.syncError?e:{...e,syncError:n};if(t.force!==!0&&e.dirty&&e.doc!==null&&To(e.doc)!==To(t.doc))return{...e,conflict:{name:t.name,reason:`the builder file changed on disk while this canvas had unsaved edits, so the two no longer describe the same flow`,origin:`canvas`,docSide:e.doc,codeSide:t.doc},resolving:!1};let r=new Set(t.doc.content.Actions.map(e=>e.Identifier));return{...e,doc:t.doc,dirty:!1,lintPending:!0,selected:e.selected!==null&&r.has(e.selected)?e.selected:null,rawFor:e.rawFor!==null&&r.has(e.rawFor)?e.rawFor:null,conflict:null,resolving:!1,syncError:n,error:null}}case`conflict`:return t.conflict.name===e.docName?{...e,conflict:t.conflict,resolving:!1}:e;case`resolving`:return{...e,resolving:t.value};case`mutated`:return e.conflict===null?t.doc===e.doc?e:{...e,doc:t.doc,dirty:!0,lintPending:!0,notice:null,error:null}:{...e,notice:{message:pl,nonce:(e.notice?.nonce??0)+1}};case`saved`:return{...e,dirty:!1,error:null};case`lint`:return{...e,findings:t.findings,blocked:t.blocked,lintPending:!1};case`select`:return{...e,selected:t.id,rawFor:null};case`raw`:return{...e,rawFor:t.id,selected:t.id};case`focus`:return{...e,selected:t.id,focus:{id:t.id,nonce:(e.focus?.nonce??0)+1}};case`notice`:return{...e,notice:t.message===null?null:{message:t.message,nonce:(e.notice?.nonce??0)+1}};case`sync-error`:return{...e,syncError:{name:t.name,path:t.path,message:t.message},notice:{message:Oc(t.path,t.message),nonce:(e.notice?.nonce??0)+1}};case`error`:return{...e,error:t.message}}}function gl(e,t,n){let r;try{r=t()}catch(t){return t instanceof Zs?(e({type:`notice`,message:t.message}),!1):(e({type:`error`,message:t instanceof Error?t.message:String(t)}),!1)}return r===void 0?(e({type:`notice`,message:n}),!1):(e({type:`mutated`,doc:r}),!0)}var _l=(0,g.createContext)(null);function vl(e=globalThis,t=!1){let n=il(e);return n===void 0?t?dl(cl()):cl():n}function yl({children:e,store:t}){let[n,r]=(0,g.useReducer)(hl,void 0,()=>ml(t??vl()));(0,g.useEffect)(()=>{bl(r,n.store)},[]);let i=(0,g.useMemo)(()=>({state:n,dispatch:r}),[n]);return(0,Y.jsx)(_l.Provider,{value:i,children:e})}function X(){let e=(0,g.useContext)(_l);if(e===null)throw Error(`useStudio outside StudioProvider`);return e}async function bl(e,t){try{let n=await t.list();e({type:`store-opened`,store:t,docList:n});let r=n[0];if(r!==void 0){let{doc:n}=await t.read(r.name);e({type:`doc-loaded`,name:r.name,doc:n})}}catch(t){e({type:`error`,message:t instanceof Error?t.message:String(t)})}}async function xl(e,t,n){try{let{doc:r}=await t.read(n);e({type:`doc-loaded`,name:n,doc:r})}catch(t){e({type:`error`,message:t instanceof Error?t.message:String(t)})}}async function Sl(e,t,n,r){try{return await t.write(n,r),e({type:`saved`}),!0}catch(t){return t instanceof el?(e({type:`conflict`,conflict:t.conflict}),!1):(e({type:`error`,message:t instanceof Error?t.message:String(t)}),!1)}}async function Cl(e,t,n,r){if(!(t instanceof nl)){e({type:`error`,message:`Only the flow-cli studio bridge can resolve a conflict.`});return}let{name:i}=n;e({type:`resolving`,value:!0});try{if(r===`doc`&&n.origin===`canvas`){let r=n.docSide;if(r===null)throw Error(`There is no canvas version to keep.`);await t.write(i,r,{force:!0}),e({type:`doc-synced`,name:i,doc:r,force:!0});return}e({type:`doc-synced`,name:i,doc:(await t.resolve(i,r)).doc,force:!0})}catch(t){e({type:`resolving`,value:!1}),e({type:`error`,message:t instanceof Error?t.message:String(t)})}}var wl={Interact:`bg-sky-100 text-sky-800 dark:bg-sky-900 dark:text-sky-200`,Set:`bg-violet-100 text-violet-800 dark:bg-violet-900 dark:text-violet-200`,Branch:`bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200`,Integrate:`bg-emerald-100 text-emerald-800 dark:bg-emerald-900 dark:text-emerald-200`,Terminate:`bg-rose-100 text-rose-800 dark:bg-rose-900 dark:text-rose-200`,generic:`bg-neutral-200 text-neutral-700 dark:bg-neutral-700 dark:text-neutral-200`};function Tl({data:e,selected:t}){let{dispatch:n}=X(),{model:r,errorCount:i,warningCount:a,handles:o,demoted:s,dangling:c}=e,u=zs(r.action.Type),d=!u||o.primary,p=!u||o.error,m=s&&!r.isGeneric;return(0,Y.jsxs)(`div`,{"data-testid":`node-${r.id}`,className:[`w-45 rounded-md border bg-white px-3 py-2 text-left shadow-sm dark:bg-neutral-900`,r.isGeneric?`border-dashed border-neutral-400 dark:border-neutral-500`:`border-neutral-300 dark:border-neutral-600`,t?`ring-2 ring-blue-500`:``].join(` `),children:[(0,Y.jsx)(f,{type:`target`,position:l.Left,className:`!bg-neutral-400`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${wl[r.category]??wl.generic}`,children:r.isGeneric?`unmodeled`:r.category}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1`,children:[r.isStart&&(0,Y.jsx)(`span`,{className:`rounded bg-blue-100 px-1.5 py-0.5 text-[10px] font-medium text-blue-800 dark:bg-blue-900 dark:text-blue-200`,children:`start`}),i>0&&(0,Y.jsx)(`span`,{"data-testid":`lint-badge-${r.id}`,title:`${i} lint error(s)`,className:`rounded-full bg-red-600 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:i}),i===0&&a>0&&(0,Y.jsx)(`span`,{"data-testid":`lint-badge-${r.id}`,title:`${a} lint warning(s)`,className:`rounded-full bg-amber-500 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:a})]})]}),(0,Y.jsx)(`div`,{className:`mt-1 truncate text-sm font-medium text-neutral-900 dark:text-neutral-100`,children:r.id}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`truncate text-xs text-neutral-500 dark:text-neutral-400`,children:r.action.Type}),r.isGeneric&&(0,Y.jsx)(`button`,{type:`button`,"data-testid":`raw-button-${r.id}`,className:`nodrag rounded border border-neutral-300 px-1 text-[10px] text-neutral-600 hover:bg-neutral-100 dark:border-neutral-600 dark:text-neutral-300 dark:hover:bg-neutral-800`,onClick:e=>{e.stopPropagation(),n({type:`raw`,id:r.id})},children:`raw`})]}),c>0&&(0,Y.jsxs)(`p`,{"data-testid":`dangling-${r.id}`,className:`mt-1 text-[10px] leading-tight text-amber-600 dark:text-amber-400`,title:`This block has transitions pointing at an Identifier the document does not contain. They are kept in the file but cannot be drawn.`,children:[c,` transition(s) point outside this flow`]}),m&&(0,Y.jsx)(`p`,{"data-testid":`demoted-${r.id}`,className:`mt-1 text-[10px] leading-tight text-amber-600 dark:text-amber-400`,title:`Generated TypeScript will use GenericBlock for this action until its parameters and transitions match the block class.`,children:`generates as GenericBlock`}),d&&(0,Y.jsx)(f,{type:`source`,id:`primary`,position:l.Right,style:{top:`40%`},title:`Drag to wire the success path (a branch, on a Compare)`,className:`!bg-neutral-400`}),p&&(0,Y.jsx)(f,{type:`source`,id:`error`,position:l.Right,style:{top:`75%`},title:`Drag to wire the next unwired error branch`,className:`!bg-red-400`})]})}var El={action:Tl},Dl={type:s.ArrowClosed,width:18,height:18};function Ol(e){return e===`error`?`error`:`primary`}function kl(e){let t=new Map;for(let n of e.edges){let e=t.get(n.source)??{primary:!1,error:!1};e[Ol(n.kind)]=!0,t.set(n.source,e)}return t}function Al(e){let t={id:e.id,source:e.source,sourceHandle:Ol(e.kind),target:e.target,label:e.label,markerEnd:Dl,reconnectable:!0};return e.kind===`error`?{...t,style:{stroke:`#dc2626`,strokeDasharray:`6 3`},labelStyle:{fill:`#dc2626`,fontSize:10}}:e.kind===`condition`?{...t,style:{stroke:`#d97706`},labelStyle:{fill:`#d97706`,fontSize:10}}:t}function jl(){let{state:e,dispatch:t}=X(),{doc:n,findings:r,focus:i}=e,{setCenter:a}=p(),s=(0,g.useMemo)(()=>n===null?{nodes:[],edges:[],dangling:[]}:Rs(n),[n]),c=(0,g.useMemo)(()=>{let e=new Map;for(let t of r){if(t.blockId===void 0)continue;let n=e.get(t.blockId)??{errors:0,warnings:0};t.severity===`error`?n.errors++:n.warnings++,e.set(t.blockId,n)}return e},[r]),l=(0,g.useMemo)(()=>n===null?new Set:Ss(n),[n]),f=(0,g.useMemo)(()=>kl(s),[s]),h=(0,g.useMemo)(()=>{let e=new Map;for(let t of s.dangling)e.set(t.source,(e.get(t.source)??0)+1);return e},[s]),_=(0,g.useMemo)(()=>s.nodes.map(t=>{let n=c.get(t.id)??{errors:0,warnings:0};return{id:t.id,type:`action`,position:t.position,data:{model:t,errorCount:n.errors,warningCount:n.warnings,handles:f.get(t.id)??{primary:!1,error:!1},demoted:l.has(t.id),dangling:h.get(t.id)??0},selected:e.selected===t.id}}),[s,c,f,l,h,e.selected]),[v,y,b]=d(_);(0,g.useEffect)(()=>y(_),[_,y]);let x=(0,g.useMemo)(()=>s.edges.map(Al),[s]);return(0,g.useEffect)(()=>{if(i===null||n===null)return;let e=n.layout?.[i.id]??s.nodes.find(e=>e.id===i.id)?.position;e!==void 0&&a(e.x+90,e.y+30,{zoom:1.2,duration:300})},[i,n,s,a]),n===null?(0,Y.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-neutral-500`,children:`No document loaded.`}):(0,Y.jsx)(`div`,{className:`min-h-0 flex-1`,"data-testid":`canvas`,children:(0,Y.jsxs)(o,{colorMode:`system`,nodeTypes:El,nodes:v,onNodesChange:b,edges:x,fitView:!0,minZoom:.1,proOptions:{hideAttribution:!0},onNodeClick:(e,n)=>t({type:`select`,id:n.id}),onPaneClick:()=>t({type:`select`,id:null}),onNodeDragStop:(e,r)=>{gl(t,()=>dc(n,r.id,r.position),`"${r.id}" is not a block in this flow.`)},onConnect:e=>{let{source:r,target:i}=e;if(r===null||i===null)return;let a=e.sourceHandle===`error`||e.sourceHandle===`primary`?e.sourceHandle:void 0;gl(t,()=>Sc(n,r,i,a),`There is no ${a===`error`?`error branch`:`transition`} "${r}" can still take to "${i}".`)},onReconnect:(e,r)=>{let{source:i,target:a}=r;i!==null&&a!==null&&gl(t,()=>Ec(n,e.id,i,a),`"${i}" cannot take that transition; it would replace one it already has.`)},children:[(0,Y.jsx)(m,{gap:16}),(0,Y.jsx)(u,{showInteractive:!1})]})})}function Ml(){return(0,Y.jsx)(c,{children:(0,Y.jsx)(jl,{})})}var Nl=1e6;function Pl(e){let t=To(e).split(`
15
+ `);return t.at(-1)===``&&t.pop(),t}function Fl(e,t){let n=[],r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];)n.push({kind:`same`,left:e[r],right:t[r]}),r++;let i=e.length,a=t.length,o=[];for(;i>r&&a>r&&e[i-1]===t[a-1];)i--,a--,o.unshift({kind:`same`,left:e[i],right:t[a]});let s=e.slice(r,i),c=t.slice(r,a),l=!1;if(s.length*c.length>Nl){l=!0;for(let e of s)n.push({kind:`removed`,left:e});for(let e of c)n.push({kind:`added`,right:e})}else if(s.length===0||c.length===0){for(let e of s)n.push({kind:`removed`,left:e});for(let e of c)n.push({kind:`added`,right:e})}else{let e=c.length+1,t=new Uint32Array((s.length+1)*e);for(let n=s.length-1;n>=0;n--)for(let r=c.length-1;r>=0;r--)t[n*e+r]=s[n]===c[r]?t[(n+1)*e+r+1]+1:Math.max(t[(n+1)*e+r],t[n*e+r+1]);let r=0,i=0;for(;r<s.length&&i<c.length;)s[r]===c[i]?(n.push({kind:`same`,left:s[r],right:c[i]}),r++,i++):t[(r+1)*e+i]>=t[r*e+i+1]?(n.push({kind:`removed`,left:s[r]}),r++):(n.push({kind:`added`,right:c[i]}),i++);for(;r<s.length;)n.push({kind:`removed`,left:s[r++]});for(;i<c.length;)n.push({kind:`added`,right:c[i++]})}return n.push(...o),{edits:n,coarse:l}}function Il(e){let t=[],n=0,r=0;for(let i=0;i<e.length;){let a=e[i];if(a.kind===`same`){t.push({kind:`same`,left:a.left,right:a.right,leftNo:++n,rightNo:++r}),i++;continue}let o=[];for(;e[i]?.kind===`removed`;)o.push(e[i++].left);let s=[];for(;e[i]?.kind===`added`;)s.push(e[i++].right);let c=Math.max(o.length,s.length);for(let e=0;e<c;e++){let i=o[e],a=s[e];i!==void 0&&a!==void 0?t.push({kind:`changed`,left:i,right:a,leftNo:++n,rightNo:++r}):i===void 0?t.push({kind:`added`,right:a,rightNo:++r}):t.push({kind:`removed`,left:i,leftNo:++n})}}return t}function Ll(e,t){let{edits:n,coarse:r}=Fl(e,t),i=Il(n);return{rows:i,identical:i.every(e=>e.kind===`same`),added:i.filter(e=>e.kind===`added`||e.kind===`changed`).length,removed:i.filter(e=>e.kind===`removed`||e.kind===`changed`).length,coarse:r}}function Rl(e,t){return Ll(e===null?[]:Pl(e),t===null?[]:Pl(t))}var zl={same:`text-neutral-500 dark:text-neutral-400`,changed:`bg-amber-50 text-amber-900 dark:bg-amber-950 dark:text-amber-100`,added:`bg-emerald-50 text-emerald-900 dark:bg-emerald-950 dark:text-emerald-100`,removed:`bg-rose-50 text-rose-900 dark:bg-rose-950 dark:text-rose-100`};function Bl({text:e,no:t,kind:n}){return(0,Y.jsxs)(`div`,{className:`flex gap-2 px-2 ${zl[n]}`,children:[(0,Y.jsx)(`span`,{className:`w-8 shrink-0 text-right text-neutral-400 tabular-nums dark:text-neutral-600`,children:t??``}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-all whitespace-pre-wrap`,children:e??``})]})}function Vl(e){let{origin:t,docSide:n}=e;return(0,g.useMemo)(()=>{if(t!==`canvas`||n===null)return null;let e=Ic(n);return e.ok?null:[...e.blockers.map(e=>`${e.rule}: ${e.message}`),...e.schemaErrors.map(e=>`schema: ${e}`)]},[t,n])}function Hl(){let{state:e,dispatch:t}=X(),n=e.conflict,r=Vl(n??{origin:`disk`,docSide:null});if(n===null)return null;let i=Rl(n.docSide,n.codeSide),a=r=>{Cl(t,e.store,n,r)};return(0,Y.jsx)(`div`,{className:`fixed inset-0 z-40 flex items-center justify-center bg-neutral-900/50 p-4`,"data-testid":`conflict-modal`,children:(0,Y.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`conflict-title`,className:`flex max-h-full w-full max-w-4xl flex-col rounded border border-neutral-300 bg-white shadow-xl dark:border-neutral-600 dark:bg-neutral-900`,children:[(0,Y.jsxs)(`header`,{className:`border-b border-neutral-200 px-4 py-3 dark:border-neutral-700`,children:[(0,Y.jsxs)(`h2`,{id:`conflict-title`,className:`text-sm font-semibold`,children:[`“`,n.name,`” changed on both sides`]}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-neutral-600 dark:text-neutral-300`,children:n.reason}),(0,Y.jsx)(`p`,{className:`mt-1 text-xs text-neutral-600 dark:text-neutral-300`,children:`Nothing has been overwritten, and editing and saving are paused until you choose. Picking a side rewrites the other one from it.`}),e.notice!==null&&(0,Y.jsx)(`p`,{"data-testid":`conflict-notice`,className:`mt-1 text-xs text-amber-700 dark:text-amber-300`,children:e.notice.message})]}),(0,Y.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-neutral-200 bg-neutral-200 text-xs font-medium dark:border-neutral-700 dark:bg-neutral-700`,children:[(0,Y.jsxs)(`div`,{className:`bg-white px-3 py-2 dark:bg-neutral-900`,children:[`Canvas ·`,` `,n.origin===`canvas`?`unsaved edits in this window`:n.name+Uc,n.docError!==void 0&&(0,Y.jsx)(`p`,{"data-testid":`conflict-doc-error`,className:`mt-1 text-red-600 dark:text-red-400`,children:n.docError}),r!==null&&(0,Y.jsxs)(`p`,{"data-testid":`conflict-doc-refused`,className:`mt-1 font-normal text-red-600 dark:text-red-400`,children:[`This version cannot be written: `,r.join(`; `),`. Keep the code version, then make the change again on the canvas.`]})]}),(0,Y.jsxs)(`div`,{className:`bg-white px-3 py-2 dark:bg-neutral-900`,children:[`Code · `,n.name,Wc,n.codeError!==void 0&&(0,Y.jsx)(`p`,{"data-testid":`conflict-code-error`,className:`mt-1 text-red-600 dark:text-red-400`,children:n.codeError})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto font-mono text-[11px] leading-5`,children:i.identical?(0,Y.jsx)(`p`,{"data-testid":`conflict-identical`,className:`p-4 text-xs text-neutral-500`,children:`The two sides describe the same flow. Either choice keeps it and re-syncs the pair.`}):(0,Y.jsx)(`div`,{"data-testid":`conflict-diff`,className:`grid grid-cols-2 gap-px bg-neutral-100 dark:bg-neutral-800`,children:i.rows.map((e,t)=>(0,Y.jsxs)(g.Fragment,{children:[(0,Y.jsx)(Bl,{text:e.left,no:e.leftNo,kind:e.kind}),(0,Y.jsx)(Bl,{text:e.right,no:e.rightNo,kind:e.kind})]},String(t)))})}),e.error!==null&&(0,Y.jsx)(`p`,{role:`alert`,"data-testid":`conflict-error`,className:`border-t border-neutral-200 px-4 py-2 text-xs break-words text-red-600 dark:border-neutral-700 dark:text-red-400`,children:e.error}),(0,Y.jsxs)(`footer`,{className:`flex items-center justify-end gap-2 border-t border-neutral-200 px-4 py-3 dark:border-neutral-700`,children:[(0,Y.jsx)(`span`,{className:`mr-auto text-xs text-neutral-500`,children:i.coarse?`The documents differ too widely to align line by line.`:`${String(i.removed)} line(s) on the canvas side, ${String(i.added)} on the code side`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`conflict-keep-doc`,disabled:e.resolving||n.docSide===null||r!==null,className:`rounded border border-neutral-300 px-3 py-1 text-xs hover:bg-neutral-100 disabled:opacity-40 dark:border-neutral-600 dark:hover:bg-neutral-800`,title:n.docSide===null?`The FlowDoc on disk cannot be read, so it cannot win.`:r===null?`Keep the canvas version and regenerate ${n.name}${Wc} from it`:`The canvas version fails the save gate, so it cannot be written: ${r.join(`; `)}`,onClick:()=>a(`doc`),children:`Keep the canvas version`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`conflict-keep-code`,disabled:e.resolving||n.codeSide===null,className:`rounded bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-40`,title:n.codeSide===null?`The builder file cannot be synthed, so it cannot win.`:`Keep the code version and rewrite ${n.name}${Uc} from it`,onClick:()=>a(`code`),children:`Keep the code version`})]})]})})}function Ul(){let{state:e,dispatch:t}=X(),{doc:n}=e,r=(0,g.useMemo)(()=>n===null?[]:Ls(n),[n]);return r.length===0?null:(0,Y.jsxs)(`section`,{"data-testid":`dangling-panel`,className:`max-h-32 shrink-0 overflow-y-auto border-t border-amber-300 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950`,children:[(0,Y.jsxs)(`h2`,{className:`mb-1 text-xs font-semibold tracking-wide text-amber-800 uppercase dark:text-amber-200`,children:[`Dangling transitions (`,r.length,`)`]}),(0,Y.jsx)(`p`,{className:`mb-1 text-[11px] text-amber-800 dark:text-amber-200`,children:`These point at a block this document does not contain. They are kept in the file and re-emitted, but they cannot be drawn. Add a block with that Identifier, or select the source block and rewire the branch.`}),(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:r.map((e,n)=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`dangling-row`,className:`flex w-full items-baseline gap-2 rounded px-1 py-0.5 text-left text-xs hover:bg-amber-100 dark:hover:bg-amber-900`,onClick:()=>t({type:`focus`,id:e.source}),children:[(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-amber-900 dark:text-amber-100`,children:e.source}),(0,Y.jsx)(`span`,{className:`shrink-0 text-amber-700 dark:text-amber-300`,children:e.label}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-amber-900 dark:text-amber-100`,children:[`→ “`,e.target,`” is not a block in this document`]})]})},`${e.source}:${e.kind}:${String(n)}`))})]})}var Wl=class extends g.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`Flow Studio crashed while rendering`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,Y.jsxs)(`div`,{role:`alert`,"data-testid":`error-boundary`,className:`flex h-screen flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,Y.jsx)(`h1`,{className:`text-sm font-semibold text-red-700 dark:text-red-300`,children:`Flow Studio hit an unexpected error`}),(0,Y.jsx)(`p`,{className:`max-w-lg font-mono text-xs break-words text-neutral-600 dark:text-neutral-300`,children:e.message}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded border border-neutral-300 px-3 py-1 text-xs hover:bg-neutral-100 dark:border-neutral-600 dark:hover:bg-neutral-800`,onClick:()=>this.setState({error:null}),children:`Try again`})]})}},Gl=lc;function Kl(e){return e===A.MessageParticipant||e===A.GetParticipantInput}function ql(e){return e===A.GetParticipantInput}function Jl(e){switch(e){case A.MessageParticipant:return[];case A.GetParticipantInput:return[{kind:`number`,key:`InputTimeLimitSeconds`,label:`Timeout (seconds)`,min:1,max:180,asString:!0}];case A.CheckHoursOfOperation:return[{kind:`ref`,key:`HoursOfOperationId`,label:`Hours of operation`,refType:`hours`,optional:!0}];case A.Compare:return[{kind:`text`,key:`ComparisonValue`,label:`Comparison value (JSONPath)`}];case A.TransferToFlow:return[{kind:`ref`,key:`ContactFlowId`,label:`Flow`,refType:`flow`}];case A.UpdateContactTargetQueue:return[{kind:`ref`,key:`QueueId`,label:`Queue`,refType:`queue`,clears:[`AgentId`]},{kind:`ref`,key:`AgentId`,label:`Agent queue`,refType:`queue`,optional:!0,clears:[`QueueId`]}];case A.UpdateContactAttributes:return[{kind:`json`,key:`Attributes`,label:`Attributes`},{kind:`select`,key:`TargetContact`,label:`Target contact`,options:[`Current`,`Related`]}];case A.UpdateContactRecordingBehavior:return[{kind:`json`,key:`RecordingBehavior`,label:`Recording behavior`}];case A.InvokeFlowModule:return[{kind:`ref`,key:`FlowModuleId`,label:`Module`,refType:`module`}];case A.InvokeLambdaFunction:return[{kind:`ref`,key:`LambdaFunctionARN`,label:`Lambda function`,refType:`lambda`},{kind:`number`,key:`InvocationTimeLimitSeconds`,label:`Timeout (seconds)`,min:1,max:8},{kind:`select`,key:`InvocationType`,label:`Invocation type`,options:[`SYNCHRONOUS`,`ASYNCHRONOUS`]},{kind:`json`,key:`ResponseValidation`,label:`Response validation`}];case A.DisconnectParticipant:case A.EndFlowExecution:case A.EndFlowModuleExecution:case A.TransferContactToQueue:return[];default:return}}var Yl=/arn:aws[a-z-]*:/,Xl=/^\$\.[A-Za-z0-9_$.[\]'-]+$/;function Zl(e,t){let n=t.trim();if(n===``)return{ok:!1,error:`Enter a token or JSONPath.`};if(Yl.test(n))return{ok:!1,error:"Literal ARNs are rejected (lint rule no-literal-arn). Use a ${cdref:type:name} token."};if(E.test(n)){let t=O(n);return t!==void 0&&t.type!==e?{ok:!1,error:`Expected a ${e} reference, got ${t.type}.`}:{ok:!0,value:n}}return Xl.test(n)?{ok:!0,value:n}:{ok:!1,error:"Not a ${cdref:"+e+`:name} token or a $.single.jsonpath identifier.`}}function Ql(e,t,n){return b.test(t)?e===`module`?n===void 0||!b.test(n)?{ok:!1,error:`Module references need a slug alias, e.g. prod.`}:{ok:!0,value:`\${cdref:module:${t}@${n}}`}:{ok:!0,value:`\${cdref:${e}:${t}}`}:{ok:!1,error:`"${t}" is not a slug (lowercase words separated by hyphens).`}}function $l(e,t){return(e.refs??[]).filter(e=>e.type===t)}var eu=`__custom__`,tu=`__new__`,nu=``;function ru({doc:e,refType:t,value:n,optional:r,onChange:i}){let a=$l(e,t),o=n!==void 0&&a.some(e=>e.token===n),[s,c]=(0,g.useState)(!o&&n!==void 0),[l,u]=(0,g.useState)(n??``),[d,f]=(0,g.useState)(null);(0,g.useEffect)(()=>{u(n??``),c(n!==void 0&&!a.some(e=>e.token===n)),f(null)},[n]);let p=e=>{let n=Zl(t,e);n.ok?(f(null),i(n.value)):f(n.error)},m=e=>{if(f(null),e===nu){if(r!==!0){f(`This reference is required. Pick one, or enter a token or JSONPath.`);return}c(!1),i(void 0)}else if(e===eu)c(!0);else if(e===tu){let e=window.prompt(`New ${t} reference name (slug, e.g. front-desk):`);if(e===null)return;let n=t===`module`?window.prompt(`Module alias (slug, e.g. prod):`)??void 0:void 0,r=Ql(t,e.trim(),n?.trim());r.ok?(c(!1),i(r.value)):f(r.error)}else c(!1),i(e)};return(0,Y.jsxs)(`div`,{className:`space-y-1`,children:[(0,Y.jsxs)(`select`,{className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-600 dark:bg-neutral-800`,value:s?eu:o?n:nu,onChange:e=>m(e.target.value),children:[(0,Y.jsx)(`option`,{value:nu,disabled:r!==!0,children:r===!0?`(not set)`:`(choose a reference)`}),a.map(e=>(0,Y.jsxs)(`option`,{value:e.token,children:[e.name,e.alias===void 0?``:`@${e.alias}`]},e.token)),(0,Y.jsx)(`option`,{value:tu,children:`new reference…`}),(0,Y.jsx)(`option`,{value:eu,children:`token or JSONPath…`})]}),s&&(0,Y.jsx)(`input`,{type:`text`,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 font-mono text-xs dark:border-neutral-600 dark:bg-neutral-800`,placeholder:`\${cdref:${t}:name} or $.Attributes.value`,value:l,onChange:e=>u(e.target.value),onBlur:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(e.target.value)}}),d!==null&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:d})]})}function iu({label:e,value:t,onCommit:n}){let r=JSON.stringify(t??{},null,2),[i,a]=(0,g.useState)(r),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(null);return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:e}),(0,Y.jsx)(`textarea`,{className:`h-28 w-full rounded border border-neutral-300 bg-white p-2 font-mono text-xs dark:border-neutral-600 dark:bg-neutral-800`,value:o?i:r,onFocus:()=>{a(r),s(!0)},onChange:e=>a(e.target.value),onBlur:()=>{s(!1);try{let e=JSON.parse(i);l(null),JSON.stringify(e)!==JSON.stringify(t??{})&&n(e)}catch{l(`Not valid JSON; change discarded.`)}}}),c!==null&&(0,Y.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-400`,children:c})]})}function au(e){let[t,n]=(0,g.useState)(e),[r,i]=(0,g.useState)(e);return e!==r&&(i(e),n(e)),[t,n]}function ou({label:e,value:t,onCommit:n}){let[r,i]=au(t);return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:e}),(0,Y.jsx)(`input`,{type:`text`,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-600 dark:bg-neutral-800`,value:r,onChange:e=>i(e.target.value),onBlur:()=>{r!==t&&n(r)}})]})}function su({field:e,value:t,error:n,onCommit:r}){let[i,a]=au(t);return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:e.label}),(0,Y.jsx)(`input`,{type:`number`,"data-testid":`number-${e.key}`,min:e.min,max:e.max,step:e.integer===!1?void 0:1,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-600 dark:bg-neutral-800`,value:i,onChange:e=>a(e.target.value),onBlur:()=>{i!==t&&r(i)}}),n!==void 0&&(0,Y.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:n})]})}function cu({value:e,onCommit:t}){let[n,r]=au(e);return(0,Y.jsx)(`textarea`,{"data-testid":`message-body`,className:`h-24 w-full rounded border border-neutral-300 bg-white p-2 text-sm dark:border-neutral-600 dark:bg-neutral-800`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{n!==e&&t(n)}})}function lu(){let{state:e,dispatch:t}=X(),[n,r]=(0,g.useState)({}),[i,a]=(0,g.useState)(null),{doc:o,selected:s}=e;if((0,g.useEffect)(()=>{r({}),a(null)},[s]),o===null||s===null)return(0,Y.jsx)(`aside`,{className:`w-72 shrink-0 border-l border-neutral-200 p-3 text-sm text-neutral-500 dark:border-neutral-700`,children:`Select a block to edit its parameters.`});let c=ac(o,s);if(c===void 0)return(0,Y.jsx)(`aside`,{className:`w-72 shrink-0 border-l border-neutral-200 p-3 text-sm text-neutral-500 dark:border-neutral-700`});let l=Jl(c.Type),u=l===void 0,d=Ss(o).has(s),f=e=>{try{t({type:`mutated`,doc:e()})}catch(e){if(e instanceof Zs){t({type:`notice`,message:e.message});return}t({type:`error`,message:e instanceof Error?e.message:String(e)})}},p=()=>{let e;try{e=_c(o,s)}catch(e){if(e instanceof Zs){t({type:`notice`,message:e.message});return}t({type:`error`,message:e instanceof Error?e.message:String(e)});return}let n=oc(o,s);(n===0||window.confirm(`${n} transition(s) point at "${s}". Deleting it removes those branches from the blocks that hold them. Delete?`))&&(t({type:`select`,id:null}),t({type:`mutated`,doc:e}))},m=e=>{let i=c.Parameters[e.key];switch(e.kind){case`text`:return(0,Y.jsx)(ou,{label:e.label,value:typeof i==`string`?i:``,onCommit:t=>f(()=>pc(o,s,e.key,t,e))},`${s}:${e.key}`);case`number`:{let a=`${s}:${e.key}`;return(0,Y.jsx)(su,{field:e,value:typeof i==`number`?String(i):typeof i==`string`?i:``,error:n[a],onCommit:n=>{let i=mc(o,s,e.key,n,e);i.ok?(r(e=>{let t={...e};return delete t[a],t}),t({type:`mutated`,doc:i.doc})):r(e=>({...e,[a]:i.error}))}},`${s}:${e.key}`)}case`select`:return(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:e.label}),(0,Y.jsxs)(`select`,{className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-600 dark:bg-neutral-800`,value:typeof i==`string`?i:``,onChange:t=>f(()=>pc(o,s,e.key,t.target.value===``?void 0:t.target.value)),children:[e.optional===!0&&(0,Y.jsx)(`option`,{value:``,children:`(not set)`}),e.options.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]})]},`${s}:${e.key}`);case`ref`:return(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:e.label}),(0,Y.jsx)(ru,{doc:o,refType:e.refType,value:typeof i==`string`?i:void 0,optional:e.optional,onChange:t=>f(()=>pc(o,s,e.key,t,e))})]},`${s}:${e.key}`);case`json`:return(0,Y.jsx)(iu,{label:e.label,value:i,onCommit:t=>f(()=>pc(o,s,e.key,t))},`${s}:${e.key}`)}},h=ql(c.Type),_=uc(c)??(h?``:`Text`),v=i?.id===s?i.kind:_,y=_===`PromptId`||_===``||typeof c.Parameters[_]!=`string`?``:c.Parameters[_],b=()=>f(()=>pc(o,s,`Text`,void 0,{clears:lc})),x=e=>{if(e!==v){if(e===`PromptId`){a({id:s,kind:e});return}if(a(null),e===``){b();return}f(()=>hc(o,s,e,y))}},S=e=>{a(null),e===void 0?_===`PromptId`&&(h?b():f(()=>hc(o,s,`Text`,``))):f(()=>hc(o,s,`PromptId`,e))},C=c.Transitions.Conditions??[];return(0,Y.jsxs)(`aside`,{"data-testid":`inspector`,className:`w-72 shrink-0 space-y-3 overflow-y-auto border-l border-neutral-200 p-3 dark:border-neutral-700`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`truncate text-sm font-semibold text-neutral-900 dark:text-neutral-100`,children:c.Identifier}),(0,Y.jsx)(`p`,{className:`text-xs text-neutral-500 dark:text-neutral-400`,children:c.Type})]}),u?(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-neutral-500 dark:text-neutral-400`,children:`This block type is not modeled yet. Its parameters are preserved verbatim and stay read-only; transitions can still be rewired on the canvas.`}),(0,Y.jsx)(`pre`,{"data-testid":`raw-json`,className:`max-h-80 overflow-auto rounded border border-neutral-200 bg-neutral-50 p-2 font-mono text-[11px] leading-snug dark:border-neutral-700 dark:bg-neutral-800`,children:JSON.stringify(c,null,2)})]}):(0,Y.jsxs)(`div`,{className:`space-y-3`,children:[d&&(0,Y.jsxs)(`p`,{"data-testid":`demoted-banner`,className:`rounded border border-amber-300 bg-amber-50 p-2 text-xs text-amber-800 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,children:[`Generated TypeScript uses GenericBlock for this block: its parameters and transitions do not yet match what the `,c.Type,` builder can express. That is normal for a block you just added and have not wired up. No edit here can put an already-expressed block into this state.`]}),Kl(c.Type)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsx)(`span`,{className:`mb-1 block text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:`Body`}),(0,Y.jsxs)(`select`,{"data-testid":`message-body-kind`,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 text-sm dark:border-neutral-600 dark:bg-neutral-800`,value:v,onChange:e=>x(e.target.value),children:[h&&(0,Y.jsx)(`option`,{value:``,children:`(none)`}),Gl.map(e=>(0,Y.jsx)(`option`,{value:e,children:e===`PromptId`?`Prompt`:e},e))]})]}),v===``?null:v===`PromptId`?(0,Y.jsx)(ru,{doc:o,refType:`prompt`,value:typeof c.Parameters.PromptId==`string`?c.Parameters.PromptId:void 0,optional:h,onChange:S}):(0,Y.jsx)(cu,{value:typeof c.Parameters[v]==`string`?c.Parameters[v]:``,onCommit:e=>f(()=>hc(o,s,v,e))},`${s}:${v}`)]}),l?.map(m),(Hs(c)||C.length>0)&&(0,Y.jsxs)(`div`,{"data-testid":`conditions`,className:`space-y-2`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-medium text-neutral-600 dark:text-neutral-300`,children:`Branches`}),C.length===0&&(0,Y.jsx)(`p`,{className:`text-xs text-neutral-400 dark:text-neutral-500`,children:`Drag from this block’s upper handle to a target to add a branch.`}),Bs(c)&&(0,Y.jsx)(`p`,{"data-testid":`menu-branch-hint`,className:`text-xs text-neutral-400 dark:text-neutral-500`,children:`Each branch answers one key: 0 to 9, * or #. A drag picks the next free key.`}),C.map((e,n)=>(0,Y.jsxs)(`div`,{"data-testid":`condition-${String(n)}`,className:`space-y-1 rounded border border-neutral-200 p-2 dark:border-neutral-700`,children:[(0,Y.jsx)(`select`,{"aria-label":`Branch ${String(n+1)} operator`,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 text-xs dark:border-neutral-600 dark:bg-neutral-800`,value:e.Condition.Operator,onChange:r=>{gl(t,()=>Cc(o,s,n,{...e.Condition,Operator:r.target.value}),`"${r.target.value}" is not an operator this branch can use.`)},children:Us.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),(0,Y.jsx)(`input`,{type:`text`,"aria-label":`Branch ${String(n+1)} operands`,placeholder:`operands, comma separated`,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 font-mono text-xs dark:border-neutral-600 dark:bg-neutral-800`,defaultValue:e.Condition.Operands.join(`, `),onBlur:r=>{let i=Gs(r.target.value);i.join(`, `)!==e.Condition.Operands.join(`, `)&&gl(t,()=>Cc(o,s,n,{...e.Condition,Operands:i}),`A branch takes between 1 and 10 operands.`)}}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsxs)(`span`,{className:`truncate text-[11px] text-neutral-500 dark:text-neutral-400`,children:[`goes to `,e.NextAction]}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded border border-neutral-300 px-1 text-[10px] text-neutral-600 hover:bg-neutral-100 dark:border-neutral-600 dark:text-neutral-300 dark:hover:bg-neutral-800`,onClick:()=>{gl(t,()=>wc(o,s,n),`Branch ${String(n+1)} is no longer there.`)},children:`remove`})]})]},`${s}:condition:${String(n)}`))]})]}),(0,Y.jsx)(`div`,{className:`border-t border-neutral-200 pt-3 dark:border-neutral-700`,children:(0,Y.jsx)(`button`,{type:`button`,"data-testid":`delete-block`,className:`rounded border border-red-300 px-2 py-1 text-xs text-red-700 hover:bg-red-50 disabled:opacity-40 dark:border-red-800 dark:text-red-300 dark:hover:bg-red-950`,disabled:o.content.StartAction===s,title:o.content.StartAction===s?`The StartAction cannot be deleted.`:`Delete this block`,onClick:p,children:`Delete block`})})]})}function uu(){let{state:e,dispatch:t}=X(),{findings:n}=e;return(0,Y.jsxs)(`section`,{"data-testid":`lint-panel`,className:`max-h-40 shrink-0 overflow-y-auto border-t border-neutral-200 bg-neutral-50 px-3 py-2 dark:border-neutral-700 dark:bg-neutral-900`,children:[(0,Y.jsxs)(`h2`,{className:`mb-1 text-xs font-semibold tracking-wide text-neutral-500 uppercase dark:text-neutral-400`,children:[`Lint `,n.length>0?`(${n.length})`:`(clean)`]}),n.length===0?(0,Y.jsx)(`p`,{className:`text-xs text-neutral-400 dark:text-neutral-500`,children:`No findings.`}):(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:n.map((e,n)=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-baseline gap-2 rounded px-1 py-0.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800`,onClick:()=>{e.blockId!==void 0&&t({type:`focus`,id:e.blockId})},children:[(0,Y.jsx)(`span`,{className:e.severity===`error`?`shrink-0 font-semibold text-red-600 dark:text-red-400`:`shrink-0 font-semibold text-amber-600 dark:text-amber-400`,children:e.severity}),(0,Y.jsx)(`span`,{className:`shrink-0 font-mono text-neutral-500 dark:text-neutral-400`,children:e.rule}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-neutral-700 dark:text-neutral-200`,children:[e.blockId===void 0?``:`${e.blockId}: `,e.message]})]})},n))})]})}var du=8e3;function fu(){let{state:e,dispatch:t}=X(),n=e.notice,r=n?.nonce;return(0,g.useEffect)(()=>{if(r===void 0)return;let e=setTimeout(()=>t({type:`notice`,message:null}),du);return()=>clearTimeout(e)},[r,t]),n===null?null:(0,Y.jsx)(`div`,{role:`status`,"data-testid":`mutation-notice`,className:`pointer-events-auto absolute bottom-3 left-1/2 z-10 max-w-xl -translate-x-1/2 rounded border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-lg dark:border-amber-700 dark:bg-amber-950 dark:text-amber-100`,children:(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`span`,{children:n.message}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,"data-testid":`dismiss-notice`,className:`shrink-0 rounded border border-amber-400 px-1 text-[10px] hover:bg-amber-100 dark:border-amber-600 dark:hover:bg-amber-900`,onClick:()=>t({type:`notice`,message:null}),children:`dismiss`})]})})}function pu(e){let t=Object.values(e.layout??{}).map(e=>e.y);return{x:40,y:t.length===0?40:Math.max(...t)+140}}function mu(){let{state:e,dispatch:t}=X(),{doc:n}=e,r=n!==null&&!cc(n);return(0,Y.jsxs)(`aside`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto p-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-neutral-500 uppercase dark:text-neutral-400`,children:`Blocks`}),r&&(0,Y.jsxs)(`p`,{"data-testid":`palette-full`,className:`text-xs text-amber-600 dark:text-amber-400`,children:[`This flow has `,250,` actions, the most Connect allows. Delete one before adding another.`]}),Ts.map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`mb-1 text-[11px] font-medium text-neutral-400 dark:text-neutral-500`,children:e.category}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:e.types.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,disabled:n===null||r,className:`w-full truncate rounded border border-neutral-200 px-2 py-1 text-left text-xs text-neutral-700 hover:bg-neutral-100 disabled:opacity-40 dark:border-neutral-700 dark:text-neutral-200 dark:hover:bg-neutral-800`,title:`Add ${e}`,onClick:()=>{if(n!==null)try{let{doc:r,id:i}=gc(n,e,pu(n));t({type:`mutated`,doc:r}),t({type:`focus`,id:i})}catch(e){t({type:e instanceof Zs?`notice`:`error`,message:e instanceof Error?e.message:String(e)})}},children:e})},e))})]},e.category))]})}function hu(e,t){if(t===``)return 0;let n=0,r=0;for(;;){let i=e.indexOf(t,r);if(i<0)return n;n++,r=i+t.length}}function gu(e){let t=k(e.content),n=e.content.Actions.map(e=>({id:e.Identifier,json:JSON.stringify(e)}));return t.map(e=>{let t=0,r=[];for(let{id:i,json:a}of n){let n=hu(a,e.token);n!==0&&(t+=n,r.push(i))}return{...e,count:t,actions:r}})}function _u(){let{state:e,dispatch:t}=X(),{doc:n}=e,[r,i]=(0,g.useState)(null),a=(0,g.useMemo)(()=>n===null?[]:gu(n),[n]);return(0,Y.jsxs)(`section`,{"data-testid":`refs-panel`,className:`min-h-0 shrink-0 overflow-y-auto border-t border-neutral-200 p-3 dark:border-neutral-700`,children:[(0,Y.jsxs)(`h2`,{className:`mb-1 text-xs font-semibold tracking-wide text-neutral-500 uppercase dark:text-neutral-400`,children:[`References `,a.length>0?`(${String(a.length)})`:``]}),a.length===0?(0,Y.jsx)(`p`,{className:`text-xs text-neutral-400 dark:text-neutral-500`,children:`No references in this flow.`}):(0,Y.jsx)(`ul`,{className:`space-y-1`,children:a.map(e=>(0,Y.jsxs)(`li`,{children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`ref-${e.token}`,title:e.token,"aria-expanded":r===e.token,className:`flex w-full items-baseline gap-1 rounded px-1 py-0.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800`,onClick:()=>{i(t=>t===e.token?null:e.token);let n=e.actions[0];n!==void 0&&t({type:`focus`,id:n})},children:[(0,Y.jsx)(`span`,{className:`shrink-0 rounded bg-neutral-200 px-1 text-[10px] text-neutral-700 dark:bg-neutral-700 dark:text-neutral-200`,children:e.type}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-neutral-800 dark:text-neutral-100`,children:[e.name,e.alias===void 0?``:`@${e.alias}`]}),(0,Y.jsx)(`span`,{"data-testid":`ref-count-${e.token}`,title:`${String(e.count)} usage(s)`,className:`shrink-0 font-mono text-neutral-500 dark:text-neutral-400`,children:e.count})]}),r===e.token&&(0,Y.jsx)(`ul`,{className:`mt-0.5 ml-3 space-y-0.5`,children:e.actions.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`button`,{type:`button`,"data-testid":`ref-action-${e}`,className:`w-full truncate rounded px-1 py-0.5 text-left text-[11px] text-neutral-600 hover:bg-neutral-100 dark:text-neutral-300 dark:hover:bg-neutral-800`,onClick:()=>t({type:`focus`,id:e}),children:e})},e))})]},e.token))})]})}var Z=(e,t)=>({kind:`arg`,key:e,value:t}),Q=e=>({kind:`comment`,text:e}),vu=()=>({kind:`blank`}),yu=(e,t,n)=>({kind:`block`,type:e,labels:t,body:n}),bu=(e,t,n)=>({kind:`objectArg`,key:e,body:t,...n});function xu(e){return`"${e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`).replaceAll(`
16
+ `,`\\n`).replaceAll(`\r`,`\\r`).replaceAll(` `,`\\t`).replaceAll("${",()=>"$${").replaceAll(`%{`,()=>`%%{`)}"`}function Su(e,t=``){let n=[];for(let r=0;r<e.length;r+=1){let i=e[r];if(i===void 0)continue;if(i.kind===`blank`){n.push(``);continue}if(i.kind===`comment`){n.push(`${t}# ${i.text}`.trimEnd());continue}if(i.kind===`block`){let e=i.labels.map(e=>` ${xu(e)}`).join(``);n.push(`${t}${i.type}${e} {`),n.push(...Su(i.body,`${t} `)),n.push(`${t}}`);continue}if(i.kind===`objectArg`){n.push(`${t}${i.key} = ${i.open??`{`}`),n.push(...Su(i.body,`${t} `)),n.push(`${t}${i.close??`}`}`);continue}let a=[],o=r;for(;o<e.length;o+=1){let t=e[o];if(t===void 0||t.kind!==`arg`)break;a.push({key:t.key,value:t.value})}let s=Math.max(...a.map(e=>e.key.length));for(let e of a)n.push(`${t}${e.key.padEnd(s)} = ${e.value}`);r=o-1}return n}function Cu(e){return`${Su(e).join(`
17
+ `).replace(/\n+$/,``)}\n`}function wu(e){return e.replaceAll("${",()=>"$${").replaceAll(`%{`,()=>`%%{`)}var Tu=`CDREF_TF_SENTINEL`;function Eu(e){let t=Tu;for(;e.includes(t);)t+=`X`;return`${t}_`}function Du(e,t){let n=Eu(JSON.stringify(e.content)),r=new Map,i=new Map,a=0;for(let[e,o]of[...t].sort((e,t)=>e[0]<t[0]?-1:1)){let t=`${n}${String(a)}_`;a+=1,r.set(e,t),i.set(t,`\${${o}}`)}let o=wu(Mo(jo(e,Object.fromEntries(r))));for(let[e,t]of i)o=o.replaceAll(e,t);return o}var Ou=`1.7.0`,ku=class extends Error{problems;constructor(e){super(`Cannot emit terraform:\n - ${e.join(`
18
+ - `)}`),this.name=`EmitTfError`,this.problems=e}},Au=`var.connect_instance_id`,ju=`connect_instance_id`,Mu=[`Generated by ${za.tf}. Do not edit by hand: edit the`,`FlowDoc and re-emit. See docs/03-tf-emitter.md.`],$=e=>{let t=e.replaceAll(`-`,`_`);return/^[0-9]/.test(t)?`_${t}`:t};function Nu(e){let t=e.alias===void 0?``:`_${$(e.alias)}`;return`${e.type}_${$(e.name)}${t}_arn`}var Pu=e=>`TODO_MISSING_ADDRESS_${e.replace(/_arn$/,``)}`,Fu=e=>`${e.type}:${e.name}${e.alias===void 0?``:`@${e.alias}`}`,Iu=e=>e.kind===`module`?`aws_connect_contact_flow_module`:`aws_connect_contact_flow`,Lu=`flow_refs`,Ru=e=>`${e.kind===`module`?`module`:`flow`}_refs_${$(e.name)}`,zu=e=>`${e.kind}:${e.name}`,Bu=(e,t)=>e<t?-1:+(e>t);function Vu(e,t,n){if(t.trim()===``){n.push(`${e} is empty`);return}/arn:aws/i.test(t)&&n.push(`${e} is a literal ARN (${t}); map to a terraform address instead`),/[\n\r]/.test(t)&&n.push(`${e} spans multiple lines (${JSON.stringify(t)})`),/#|\/\/|\/\*/.test(t)&&n.push(`${e} contains a comment marker (${t})`)}function Hu(e){let t=[];e.length===0&&t.push(`no documents to emit`);let n=new Map;for(let r of e){if(!b.test(r.name)){t.push(`document name "${r.name}" is not a slug`);continue}r.kind===`module`&&r.connectType!==`MODULE`&&t.push(`module "${r.name}" has connectType ${r.connectType}, expected MODULE`),r.kind===`flow`&&r.connectType===`MODULE`&&t.push(`flow "${r.name}" has connectType MODULE; emit it as kind "module"`);let e=`${Iu(r)}.${$(r.name)}`;n.get(e)===void 0?n.set(e,r.name):t.push(`two documents both emit ${e}`)}if(t.length>0)throw new ku(t);return[...e].sort((e,t)=>Bu(e.name,t.name)||Bu(e.kind,t.kind))}function Uu(e,t,n){let r=new Set(e.filter(e=>e.kind===`flow`).map(e=>e.name)),i=new Set(e.filter(e=>e.kind===`module`).map(e=>e.name)),a=new Map;for(let t of e)for(let e of k(t.content))a.set(e.token,e);let o=new Map,s=[];for(let e of[...a.values()].sort((e,t)=>Bu(e.token,t.token))){let a=Nu(e),c=o.get(a);if(c!==void 0){n.push(`${e.token} and ${c} both map to local.flow_refs.${a}`);continue}o.set(a,e.token);let l=Fu(e),u=t[e.token]??t[l]??t[a];u!==void 0&&Vu(`address for ${e.token}`,u,n);let d;if(e.type===`module`&&e.alias!==void 0&&i.has(e.name)?d=`awscc_connect_contact_flow_module_alias.${$(e.name)}_${$(e.alias)}.contact_flow_module_alias_arn`:e.type===`flow`&&r.has(e.name)&&(d=`aws_connect_contact_flow.${$(e.name)}.arn`),d!==void 0){let t=u===void 0?void 0:l;s.push({entry:e,variable:a,expression:d,source:`set`,...t?{shadowed:t}:{}})}else u===void 0?s.push({entry:e,variable:a,expression:Pu(a),source:`missing`}):s.push({entry:e,variable:a,expression:u,source:`map`})}return s}function Wu(e){let t=new Set(e.filter(e=>e.kind===`module`).map(e=>e.name)),n=new Map;for(let e of t)n.set(e,new Set);for(let t of e)for(let e of k(t.content))e.type===`module`&&e.alias!==void 0&&n.get(e.name)?.add(e.alias);return new Map([...n].map(([e,t])=>[e,[...t].sort(Bu)]))}var Gu=`https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_contact_flow`,Ku=`https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/connect_contact_flow_module`,qu=`https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/connect_contact_flow_module_version`,Ju=`https://registry.terraform.io/providers/hashicorp/awscc/latest/docs/resources/connect_contact_flow_module_alias`,Yu=`https://docs.aws.amazon.com/connect/latest/APIReference/API_CreateContactFlowVersion.html`;function Xu(e,t,n){let r=Wu(e),i=e.some(e=>e.kind===`module`),a=Mu.map(Q);a.push(Q(``),Q(`Flow content is rendered from flows/<name>.flow.tftpl with the`),Q(`addresses in flow_refs.tf. Provider, credential, and backend`),Q(`configuration is yours; versions.tf.example lists what this needs.`),Q(``),Q(Gu),Q(Ku)),i&&a.push(Q(``),Q(`Modules carry versions and aliases; full flows do not.`),Q(`CreateContactFlowVersion "only supports creating versions for`),Q(`flows of type Campaign", so a flow updates its content in place`),Q(`while a module pins content behind an alias.`),Q(Yu));for(let i of e){let e=(n.get(zu(i))??[]).length>0?Ru(i):Lu,o=`templatefile("\${path.module}/flows/${i.name}.flow.tftpl", local.${e})`,s=[Z(`instance_id`,t),Z(`name`,xu(i.name))];if(i.kind===`flow`&&s.push(Z(`type`,xu(i.connectType))),s.push(Z(`content`,o)),a.push(vu(),yu(`resource`,[Iu(i),$(i.name)],s)),i.kind!==`module`)continue;let c=`aws_connect_contact_flow_module.${$(i.name)}.arn`;a.push(vu(),Q(`Snapshot of the module content as it stands when this resource is`),Q(`created. Replace it after a content change so the aliases below`),Q(`serve the new content.`),Q(qu),yu(`resource`,[`awscc_connect_contact_flow_module_version`,$(i.name)],[Z(`contact_flow_module_id`,c)]));for(let e of r.get(i.name)??[])a.push(vu(),Q(Ju),yu(`resource`,[`awscc_connect_contact_flow_module_alias`,`${$(i.name)}_${$(e)}`],[Z(`contact_flow_module_id`,c),Z(`contact_flow_module_version`,`awscc_connect_contact_flow_module_version.${$(i.name)}.version`),Z(`name`,xu(e))]))}return Cu(a)}function Zu(e,t,n){let r=Mu.map(Q);r.push(Q(``),Q(`One entry per reference token in the emitted flow set, named`),Q(`<type>_<name>_arn with hyphens as underscores and the module alias`),Q(`folded in. Values are terraform addresses, never literal ARNs.`));let i=[];for(let e of t)e.source!==`set`&&(e.source===`missing`&&i.push(Q(`TODO: no terraform address for ${e.entry.token}.`),Q(`Add one to the address map under key "${Fu(e.entry)}"`),Q(`and re-emit. Until then this placeholder is an undeclared`),Q("reference, so `terraform validate` and `tofu validate` fail.")),i.push(Z(e.variable,e.expression)));i.length===0&&i.push(Q(`No reference resolves through this map.`));let a=[bu(Lu,i)];for(let t of e){let e=n.get(zu(t))??[];if(e.length===0)continue;let r=[];for(let t of e)t.shadowed!==void 0&&r.push(Q(`Address map entry "${t.shadowed}" ignored: this set emits`),Q(`the resource itself, so the reference resolves to it.`)),r.push(Z(t.variable,t.expression));a.push(vu(),Q(`${t.name} references a resource this set emits. Its addresses`),Q(`go in a local of their own: in the shared map they would make`),Q(`that map depend on resources rendered from it, which both tools`),Q(`report as a dependency cycle.`),bu(Ru(t),r,{open:`merge(local.${Lu}, {`,close:`})`}))}return r.push(vu(),yu(`locals`,[],a)),Cu(r)}function Qu(){let e=Mu.map(Q);return e.push(vu(),yu(`variable`,[ju],[Z(`description`,xu(`Identifier of the Amazon Connect instance that holds these flows.`)),Z(`type`,`string`)])),Cu(e)}function $u(e){let t=[bu(`aws`,[Z(`source`,xu(`hashicorp/aws`)),Z(`version`,xu(`>= 5.0`))])];e&&t.push(vu(),bu(`awscc`,[Z(`source`,xu(`hashicorp/awscc`)),Z(`version`,xu(`>= 1.74`))]));let n=Mu.map(Q);return n.push(Q(``),Q(`Example only. This file is not loaded by terraform or tofu, which`),Q(`read *.tf; copy what you need into your own configuration. No`),Q(`provider credentials and no backend configuration are emitted.`),Q(``),Q(`The version constraint below is what both tools understand:`),Q(`this output uses nothing newer than Terraform 1.8 / OpenTofu 1.7.`)),e&&n.push(Q(``),Q(`awscc is needed for the module version and alias resources; it`),Q(`carries them and the aws provider does not.`)),n.push(vu(),yu(`terraform`,[],[Z(`required_version`,xu(`>= ${Ou}`)),vu(),yu(`required_providers`,[],t)])),Cu(n)}function ed(e,t={}){let n=Hu(e),r=[],i=t.instanceIdExpression??Au;t.instanceIdExpression!==void 0&&Vu(`instanceIdExpression`,t.instanceIdExpression,r);let a=t.addressMap??{};for(let e of Object.keys(a))e.startsWith("${")&&O(e)===void 0&&r.push(`address map key "${e}" looks like a token but does not parse as one`);let o=Uu(n,a,r);if(r.length>0)throw new ku(r);let s=new Map(o.filter(e=>e.source===`set`).map(e=>[e.entry.token,e])),c=new Map(n.map(e=>[zu(e),k(e.content).map(e=>s.get(e.token)).filter(e=>e!==void 0)])),l=new Map(o.map(e=>[e.entry.token,e.variable])),u={"flow_refs.tf":Zu(n,o,c),"flows.tf":Xu(n,i,c),"versions.tf.example":$u(n.some(e=>e.kind===`module`))};for(let e of n)u[`flows/${e.name}.flow.tftpl`]=Du(e,l);return t.instanceIdExpression===void 0&&(u[`variables.tf`]=Qu()),{files:Object.fromEntries(Object.entries(u).sort(([e],[t])=>Bu(e,t)))}}var td=`flow-stack.ts`,nd=[`hours`,`lambda`,`lex`,`prompt`,`queue`],rd={flow:`ARN of a contact flow not managed by this FlowSet`,hours:`ARN of the hours of operation, e.g. hours.attrHoursOfOperationArn`,lambda:`ARN of the Lambda function, e.g. fn.functionArn`,lex:`ARN of the Lex bot alias`,prompt:`ARN of the prompt`,queue:`ARN of the queue, e.g. queue.attrQueueArn`},id={flow:`contact flow`,hours:`hours of operation`,lambda:`Lambda function`,lex:`Lex bot alias`,prompt:`prompt`,queue:`queue`};function ad(e){let t=new Map;for(let n of e)for(let e of[...n.refs??[],...k(n.content)]){if(e.type===`module`)continue;let n=t.get(e.type)??new Set;n.add(e.name),t.set(e.type,n)}return new Map([...t].map(([e,t])=>[e,[...t].sort()]))}function od(e){return e<=0?`.`:Array.from({length:e},()=>`..`).join(`/`)}function sd(e,t){let n=rd[e]??`ARN of the referenced resource`,r=id[e]??e;return[...t.length===0?[` // No document in this set references a ${r}.`]:[` // TODO: return the ${n}.`,` // Names referenced: ${t.join(`, `)}.`],` ${e}: (name) => {`,t.length===0?` throw new Error(\`Unexpected ${e} reference "\${name}".\`);`:` throw new Error(\`TODO: bind ${e} "\${name}" to an ARN.\`);`,` },`]}function cd({docs:e,source:t}){let n=ad(e),r=[...nd];(n.get(`flow`)??[]).length>0&&r.unshift(`flow`);let i=[...n].filter(([,e])=>e.length>0).map(([e])=>e).sort();return["// Generated by `flow-cli emit --target cdk` as a starting point, then yours to",`// keep: re-running the command overwrites this file, so move it or rename it`,`// once you have edited it.`,`//`,`// Documents in the set: ${e.map(e=>`${e.kind} ${e.name}`).sort().join(`, `)}.`,`//`,`// FlowSet reads every *.flowdoc.json in the source directory at synth time and`,`// creates AWS::Connect::ContactFlow and AWS::Connect::ContactFlowModule`,`// resources, publishing a module version and repointing its alias whenever the`,`// module content changes. See the ${za.cdk} README.`,``,`import { fileURLToPath } from "node:url";`,``,`import { Stack, type StackProps } from "aws-cdk-lib";`,`import { FlowSet, type TokenBinder } from "${za.cdk}";`,`import type { Construct } from "constructs";`,``,`/**`,` * Directory holding the FlowDocs. Resolved against this file rather than the`," * working directory, so `cdk synth` works from the project root, from here, or",` * from anywhere else.`,` */`,`const FLOW_DOCS = fileURLToPath(new URL(${JSON.stringify(t)}, import.meta.url));`,``,`/**`,` * Resolves each reference token in the documents to a CloudFormation token,`,` * normally a construct attribute. ${za.cdk} inserts what you`,` * return byte for byte, so CDK tokens pass through and CloudFormation`,` * resolves them at deploy time. Never return a literal ARN here.`,` *`,i.length===0?` * These documents contain no references.`:` * These documents reference: ${i.join(`, `)}.`,` */`,`const binder: TokenBinder = {`,...r.flatMap(e=>sd(e,n.get(e)??[])),`};`,``,`export interface FlowStackProps extends StackProps {`,` /** ARN of the Amazon Connect instance these flows deploy into. */`,` instanceArn: string;`,`}`,``,`export class FlowStack extends Stack {`,` constructor(scope: Construct, id: string, props: FlowStackProps) {`,` super(scope, id, props);`,``,` new FlowSet(this, "Flows", {`,` instanceArn: props.instanceArn,`,` source: FLOW_DOCS,`,` binder,`,` });`,` }`,`}`].join(`
19
+ `)+`
20
+ `}function ld(e){return`${e.name}.flowdoc.json`}function ud(e){return Rc(e),To(e)}function dd(e,t,n){let r=URL.createObjectURL(new Blob([t],{type:n})),i=document.createElement(`a`);i.href=r,i.download=e,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}function fd(e){dd(ld(e),ud(e),`application/json`)}var pd=class extends Error{missingTokens;constructor(e){super(`Cannot export: ${String(e.length)} token(s) have no resource map entry: `+e.join(`, `)),this.name=`ExportMapError`,this.missingTokens=e}},md=(e,t)=>e<t?-1:+(e>t),hd=e=>Object.fromEntries(Object.entries(e).sort(([e],[t])=>md(e,t)));function gd(e){if(e.length===0)throw Error(`There is nothing to export.`);for(let t of e)Rc(t);return e}function _d(e){if(!qc(e))throw Error(`"${e}" is not a usable subdirectory: use POSIX segments of letters, digits, dot, dash, and underscore, at most three deep.`);return e}var vd=e=>e===``?0:e.split(`/`).length;function yd(e){let t=_d(e.subdir??``),n=gd(e.docs);return{target:`cdk`,subdir:t,files:{[td]:cd({docs:n,source:od(vd(t))})}}}function bd(e){return{target:`tf`,subdir:_d(e.subdir??``),files:hd(ed(gd(e.docs),{addressMap:e.addressMap}).files)}}function xd(e){let t=_d(e.subdir??``),n=gd(e.docs),r=new Set,i={};for(let t of n)try{i[`${t.name}.json`]=Mo(jo(t,e.resourceMap))}catch(e){if(!(e instanceof Eo))throw e;for(let t of e.missingTokens)r.add(t)}if(r.size>0)throw new pd([...r].sort(md));return{target:`raw`,subdir:t,files:hd(i)}}function Sd(e){switch(e.target){case`cdk`:return yd(e);case`tf`:return bd(e);case`raw`:return xd(e)}}var Cd=(e,t)=>t===``?e:`${e.replace(/\/$/,``)}/${t}`,wd=class{store;kind=`bridge`;constructor(e){this.store=e}destination(e){return Cd(this.store.info.dir,e)}async deliver(e){let t=await this.store.postExport({target:e.target,files:e.files,subdir:e.subdir}),n=Object.keys(e.files).sort();return{kind:`bridge`,target:e.target,destination:this.destination(e.subdir),files:n.map((e,n)=>({path:e,wrote:t.paths[n]??e}))}}};function Td(e){return e.endsWith(`.json`)?`application/json`:`text/plain`}var Ed=class{kind=`download`;destination(){return`your downloads folder`}deliver(e){let t=[];for(let n of Object.keys(e.files).sort()){let r=n.replaceAll(`/`,`-`);dd(r,e.files[n]??``,Td(n)),t.push({path:n,wrote:r})}return Promise.resolve({kind:`download`,target:e.target,destination:this.destination(),files:t})}},Dd=class{kind=`preview`;destination(){return`this page (read-only demo: nothing is downloaded or written)`}deliver(e){let t=Object.keys(e.files).sort();return Promise.resolve({kind:`preview`,target:e.target,destination:this.destination(),files:t.map(e=>({path:e,wrote:e})),contents:Object.fromEntries(t.map(t=>[t,e.files[t]??``]))})}};function Od(e){return e instanceof nl?new wd(e):e.readOnly?new Dd:new Ed}async function kd(e,t){return t.deliver(Sd(e))}async function Ad(e,t,n){let r=await e.list(),i=[];for(let a of r){if(a.name===t&&n!==null){i.push(n);continue}i.push((await e.read(a.name)).doc)}return n!==null&&!i.includes(n)&&i.push(n),i.sort((e,t)=>e.name<t.name?-1:+(e.name>t.name))}var jd=(e,t)=>e<t?-1:+(e>t),Md=e=>{let t=e.replaceAll(`-`,`_`);return/^[0-9]/.test(t)?`_${t}`:t},Nd={queue:e=>`aws_connect_queue.${e}.arn`,hours:e=>`aws_connect_hours_of_operation.${e}.arn`,lambda:e=>`aws_lambda_function.${e}.arn`,prompt:e=>`data.aws_connect_prompt.${e}.arn`,flow:e=>`aws_connect_contact_flow.${e}.arn`,module:e=>`aws_connect_contact_flow_module.${e}.arn`,lex:e=>`var.${e}_bot_alias_arn`};function Pd(e){let t=e.alias===void 0?e.name:`${e.name}-${e.alias}`;return Nd[e.type](Md(t))}var Fd=e=>`${e.type}:${e.name}${e.alias===void 0?``:`@${e.alias}`}`;function Id(e){let t=new Map;for(let n of e)for(let e of k(n.content)){let r=t.get(e.token);r===void 0?t.set(e.token,{...e,key:Fd(e),docs:[n.name]}):r.docs.includes(n.name)||r.docs.push(n.name)}for(let e of t.values())e.docs.sort(jd);return[...t.values()].sort((e,t)=>jd(e.token,t.token))}var Ld=/TODO: no terraform address for (\S+?)\.$/gm;function Rd(e,t){return[...(ed(e,{addressMap:t}).files[`flow_refs.tf`]??``).matchAll(Ld)].map(e=>e[1]??``).sort(jd)}function zd(e){let t=e.trim();return t===``?{ok:!1,error:`Enter a terraform address, or leave it unmapped.`}:Yl.test(t)||/arn:aws/i.test(t)?{ok:!1,error:`Literal ARNs are rejected (lint rule no-literal-arn). Use a terraform address such as aws_connect_queue.front_desk.arn.`}:/[\n\r]/.test(t)?{ok:!1,error:`An address is a single line of HCL.`}:/#|\/\/|\/\*/.test(t)?{ok:!1,error:`An address may not contain a comment marker.`}:{ok:!0,value:t}}function Bd(e){let t=e.trim();return t===``?{ok:!1,error:`Enter the resolved value for this reference.`}:{ok:!0,value:t}}function Vd(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,t.trim()]).filter(([,e])=>e!==``).sort(([e],[t])=>jd(e,t)))}var Hd=[{id:`tf`,label:`Terraform`,blurb:`aws_connect_contact_flow resources plus .tftpl content, from ${za.tf}. Give every reference a terraform address, never a literal ARN.`},{id:`cdk`,label:`CDK`,blurb:"A FlowSet stack scaffold with a TODO TokenBinder, one entry per reference type this document set uses. Same bytes as `flow-cli emit --target cdk`."},{id:`raw`,label:`Raw JSON`,blurb:`Materialized Flow language content for console import or debugging. Values here are the resolved resources themselves, so ARNs belong in this map.`}];function Ud(e){return e instanceof pd?`${String(e.missingTokens.length)} reference(s) have no resource map entry: ${e.missingTokens.join(`, `)}`:e instanceof ku?e.problems.join(`; `):e instanceof Error?e.message:String(e)}function Wd({refEntry:e,mapKey:t,value:n,error:r,missing:i,missingNote:a,testIdPrefix:o,placeholder:s,onChange:c}){return(0,Y.jsxs)(`tr`,{className:`align-top`,children:[(0,Y.jsx)(`td`,{className:`py-1 pr-2 text-xs whitespace-nowrap text-neutral-500`,children:e.type}),(0,Y.jsxs)(`td`,{className:`py-1 pr-2 font-mono text-xs break-all`,children:[e.name,e.alias===void 0?``:`@${e.alias}`]}),(0,Y.jsxs)(`td`,{className:`py-1`,children:[(0,Y.jsx)(`input`,{type:`text`,"data-testid":`${o}-${t}`,"aria-label":`Value for ${e.token}`,className:`w-full rounded border border-neutral-300 bg-white px-2 py-1 font-mono text-xs dark:border-neutral-600 dark:bg-neutral-800`,placeholder:s,value:n,onChange:e=>c(e.target.value)}),r!==null&&(0,Y.jsx)(`p`,{"data-testid":`${o}-error-${t}`,className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:r}),r===null&&i&&(0,Y.jsx)(`p`,{"data-testid":`${o}-missing-${t}`,className:`mt-1 text-xs text-amber-600 dark:text-amber-400`,children:a})]})]})}function Gd({onClose:e}){let{state:t}=X(),[n,r]=(0,g.useState)(`tf`),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)({}),[u,d]=(0,g.useState)({}),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(null),{store:y,docName:b,doc:x}=t;(0,g.useEffect)(()=>{let e=!0;return Ad(y,b,x).then(t=>{e&&s(t)}).catch(t=>{e&&v(Ud(t))}),()=>{e=!1}},[y,b,x]);let S=(0,g.useMemo)(()=>o===null?[]:Id(o),[o]),C=(0,g.useMemo)(()=>Vd(c),[c]),w=(0,g.useMemo)(()=>Vd(u),[u]),T=(0,g.useMemo)(()=>{let e={};for(let[t,n]of Object.entries(c)){if(n.trim()===``)continue;let r=zd(n);r.ok||(e[t]=r.error)}return e},[c]),E=(0,g.useMemo)(()=>{let e={};for(let[t,n]of Object.entries(u)){if(n===``)continue;let r=Bd(n);r.ok||(e[t]=r.error)}return e},[u]),D=(0,g.useMemo)(()=>{if(o===null||n!==`tf`||Object.keys(T).length>0)return{missing:[],error:null};try{return{missing:Rd(o,C),error:null}}catch(e){return{missing:[],error:Ud(e)}}},[o,n,C,T]),O=D.missing,k=S.filter(e=>w[e.token]===void 0),A=(0,g.useMemo)(()=>o===null?[]:[...ad(o)].filter(([,e])=>e.length>0).map(([e,t])=>`${e} (${t.join(`, `)})`),[o]),j=(0,g.useMemo)(()=>Od(y),[y]),ee=n===`tf`?Object.keys(T).length>0||D.error!==null:n===`raw`&&Object.keys(E).length>0,M=async()=>{if(o!==null){p(!0),v(null),h(null);try{h(await kd(n===`tf`?{target:`tf`,docs:o,subdir:i,addressMap:C}:n===`raw`?{target:`raw`,docs:o,subdir:i,resourceMap:w}:{target:`cdk`,docs:o,subdir:i},j))}catch(e){v(Ud(e))}finally{p(!1)}}},N=Hd.find(e=>e.id===n);return(0,Y.jsx)(`div`,{className:`fixed inset-0 z-30 flex items-start justify-center bg-neutral-900/50 p-6`,role:`dialog`,"aria-modal":`true`,"aria-label":`Export`,"data-testid":`export-dialog`,children:(0,Y.jsxs)(`div`,{className:`flex max-h-full w-[46rem] flex-col overflow-auto rounded border border-neutral-300 bg-white p-4 shadow-lg dark:border-neutral-600 dark:bg-neutral-900`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Export`}),(0,Y.jsx)(`span`,{className:`flex-1`}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`export-close`,className:`rounded border border-neutral-300 px-2 py-1 text-xs dark:border-neutral-600`,onClick:e,children:`Close`})]}),(0,Y.jsx)(`div`,{className:`mt-3 flex gap-2`,children:Hd.map(e=>(0,Y.jsxs)(`label`,{className:`cursor-pointer rounded border px-2 py-1 text-xs ${n===e.id?`border-blue-600 bg-blue-50 dark:bg-blue-950`:`border-neutral-300 dark:border-neutral-600`}`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:`export-target`,className:`mr-1`,"data-testid":`export-target-${e.id}`,checked:n===e.id,onChange:()=>{r(e.id),h(null),v(null)}}),e.label]},e.id))}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs text-neutral-500`,children:N?.blurb}),(0,Y.jsxs)(`label`,{className:`mt-3 block text-xs text-neutral-500`,children:[`Subdirectory (optional)`,(0,Y.jsx)(`input`,{type:`text`,"data-testid":`export-subdir`,className:`mt-1 w-full rounded border border-neutral-300 bg-white px-2 py-1 font-mono text-xs dark:border-neutral-600 dark:bg-neutral-800`,placeholder:`infra`,value:i,onChange:e=>a(e.target.value)})]}),(0,Y.jsxs)(`p`,{className:`mt-1 text-xs text-neutral-500`,"data-testid":`export-destination`,children:[j.kind===`bridge`?`Writes to `:j.kind===`preview`?`Shows in `:`Downloads to `,(0,Y.jsx)(`span`,{className:`font-mono`,children:j.destination(i)})]}),o===null?(0,Y.jsx)(`p`,{className:`mt-4 text-xs text-neutral-500`,children:`Loading documents…`}):(0,Y.jsxs)(`div`,{className:`mt-4`,children:[n===`cdk`&&(0,Y.jsx)(`div`,{"data-testid":`export-binder-types`,className:`text-xs text-neutral-500`,children:A.length===0?`These documents contain no references, so the binder is a stub.`:`TODO binder entries for: ${A.join(`, `)}.`}),n===`tf`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`table`,{className:`w-full table-auto`,children:(0,Y.jsx)(`tbody`,{children:S.map(e=>(0,Y.jsx)(Wd,{refEntry:e,mapKey:e.key,value:c[e.key]??``,error:T[e.key]??null,missing:O.includes(e.token),missingNote:`No address yet: this becomes a TODO placeholder that fails validate.`,testIdPrefix:`export-address`,placeholder:Pd(e),onChange:t=>{l(n=>({...n,[e.key]:t})),v(null)}},e.token))})}),D.error===null?(0,Y.jsx)(`p`,{className:`mt-2 text-xs`,"data-testid":`export-missing`,children:O.length===0?`All ${String(S.length)} reference(s) have an address.`:`${String(O.length)} of ${String(S.length)} reference(s) still unmapped: ${O.join(`, `)}`}):(0,Y.jsxs)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,"data-testid":`export-scan-error`,children:[`These documents cannot be emitted as they stand: `,D.error]})]}),n===`raw`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`table`,{className:`w-full table-auto`,children:(0,Y.jsx)(`tbody`,{children:S.map(e=>(0,Y.jsx)(Wd,{refEntry:e,mapKey:e.token,value:u[e.token]??``,error:E[e.token]??null,missing:w[e.token]===void 0,missingNote:`No value yet: the export refuses an incomplete resource map.`,testIdPrefix:`export-resource`,placeholder:`arn:aws:connect:…`,onChange:t=>{d(n=>({...n,[e.token]:t})),v(null)}},e.token))})}),(0,Y.jsx)(`p`,{className:`mt-2 text-xs`,"data-testid":`export-missing`,children:k.length===0?`All ${String(S.length)} reference(s) are mapped.`:`${String(k.length)} of ${String(S.length)} reference(s) unmapped: ${k.map(e=>e.token).join(`, `)}`})]})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,Y.jsx)(`button`,{type:`button`,"data-testid":`export-run`,className:`rounded bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-40`,disabled:o===null||f||ee,onClick:()=>void M(),children:`Export`}),ee&&(0,Y.jsx)(`span`,{"data-testid":`export-blocked`,className:`text-xs text-red-600 dark:text-red-400`,children:D.error===null?`Fix the highlighted map entries first.`:`Fix what the emitter reported above first.`})]}),_!==null&&(0,Y.jsx)(`p`,{role:`alert`,"data-testid":`export-error`,className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:_}),m!==null&&(0,Y.jsxs)(`div`,{"data-testid":`export-result`,className:`mt-3 text-xs text-neutral-600 dark:text-neutral-300`,children:[(0,Y.jsxs)(`p`,{children:[m.kind===`bridge`?`Wrote`:m.kind===`preview`?`Generated`:`Downloaded`,` `,m.files.length,` file(s) to `,m.destination,`:`]}),(0,Y.jsx)(`ul`,{className:`mt-1 font-mono`,children:m.files.map(e=>(0,Y.jsxs)(`li`,{children:[e.path,e.path===e.wrote?``:` → ${e.wrote}`]},e.path))}),m.contents!==void 0&&Object.entries(m.contents).map(([e,t])=>(0,Y.jsxs)(`details`,{className:`mt-2`,open:m.files.length===1,children:[(0,Y.jsx)(`summary`,{className:`cursor-pointer font-mono`,children:e}),(0,Y.jsx)(`pre`,{"data-testid":`export-preview-${e}`,className:`mt-1 max-h-80 overflow-auto rounded border border-neutral-200 bg-neutral-50 p-2 font-mono text-xs whitespace-pre dark:border-neutral-700 dark:bg-neutral-950`,children:t})]},e))]})]})})}var Kd=`.flowdoc.json`;function qd(){return typeof window<`u`&&typeof window.showDirectoryPicker==`function`}var Jd=class{label;dir;persistent=!0;readOnly=!1;constructor(e,t){this.label=e,this.dir=t}async list(){let e=[];for await(let t of this.dir.values())t.kind===`file`&&t.name.endsWith(`.flowdoc.json`)&&e.push(t.name.slice(0,-13));return e.sort().map(e=>({name:e}))}async read(e){let t=await(await(await this.dir.getFileHandle(`${e}${Kd}`)).getFile()).text();try{return{doc:zc(t),text:t}}catch(t){throw Error(`${e}${Kd}: ${t instanceof Error?t.message:String(t)}`,{cause:t})}}async write(e,t){Rc(t);let n=await(await this.dir.getFileHandle(`${e}${Kd}`,{create:!0})).createWritable();await n.write(To(t)),await n.close()}};async function Yd(){if(!qd()||window.showDirectoryPicker===void 0)throw Error(`This browser does not support the File System Access API.`);let e=await window.showDirectoryPicker({mode:`readwrite`});return new Jd(e.name,e)}function Xd(){let{state:e,dispatch:t}=X(),{doc:n,docName:r,docList:i,store:a,dirty:o,blocked:s,lintPending:c,findings:l}=e,u=(0,g.useRef)(null),[d,f]=(0,g.useState)(!1),p=a.readOnly,m=p?`Export`:`Save`,h=new Set(jc),_=l.filter(e=>h.has(e.rule)),v=(0,g.useMemo)(()=>n===null?[]:Fc(n),[n]),y=s||c||v.length>0||e.conflict!==null,b=async e=>{try{let n=zc(await e.text());await bl(t,new ol(e.name,[n]))}catch(e){t({type:`error`,message:e instanceof Error?e.message:String(e)})}},x=async()=>{n!==null&&r!==null&&await Sl(t,a,r,n)};return(0,Y.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-neutral-200 bg-white px-3 py-2 dark:border-neutral-700 dark:bg-neutral-900`,children:[(0,Y.jsx)(`h1`,{className:`text-sm font-semibold text-neutral-900 dark:text-neutral-100`,children:`Flow Studio`}),(0,Y.jsx)(`select`,{"aria-label":`Document`,className:`rounded border border-neutral-300 bg-white px-2 py-1 text-xs dark:border-neutral-600 dark:bg-neutral-800`,value:r??``,onChange:e=>void xl(t,a,e.target.value),children:i.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,Y.jsxs)(`span`,{className:`text-xs text-neutral-400 dark:text-neutral-500`,children:[a.label,o?p?` · edited in this tab`:` · unsaved changes`:``]}),p&&(0,Y.jsx)(`span`,{"data-testid":`read-only-badge`,className:`rounded border border-amber-300 bg-amber-50 px-2 py-0.5 text-xs text-amber-800 dark:border-amber-700 dark:bg-amber-950 dark:text-amber-200`,title:`Edits stay in this tab and are not saved. Reload the page to restore the demo flow.`,children:`Read-only demo`}),e.syncError!==null&&(0,Y.jsxs)(`span`,{"data-testid":`sync-error`,role:`status`,className:`max-w-96 truncate rounded border border-red-300 bg-red-50 px-2 py-0.5 text-xs text-red-700 dark:border-red-800 dark:bg-red-950 dark:text-red-300`,"aria-label":Oc(e.syncError.path,e.syncError.message),title:Oc(e.syncError.path,e.syncError.message),children:[`Code out of sync: `,Dc(e.syncError.path)]}),(0,Y.jsx)(`span`,{className:`flex-1`}),!p&&(0,Y.jsx)(`input`,{ref:u,type:`file`,accept:`.json,application/json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t!==void 0&&b(t),e.target.value=``}}),!p&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded border border-neutral-300 px-2 py-1 text-xs hover:bg-neutral-100 dark:border-neutral-600 dark:hover:bg-neutral-800`,onClick:()=>u.current?.click(),children:`Open file`}),!p&&qd()&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded border border-neutral-300 px-2 py-1 text-xs hover:bg-neutral-100 dark:border-neutral-600 dark:hover:bg-neutral-800`,onClick:()=>{Yd().then(e=>bl(t,e)).catch(e=>{e instanceof DOMException&&e.name===`AbortError`||t({type:`error`,message:e instanceof Error?e.message:String(e)})})},children:`Open folder`}),!p&&(0,Y.jsx)(`button`,{type:`button`,className:`rounded border border-neutral-300 px-2 py-1 text-xs hover:bg-neutral-100 disabled:opacity-40 dark:border-neutral-600 dark:hover:bg-neutral-800`,"data-testid":`export-button`,disabled:n===null||y,title:y?`Export is a save: it is disabled until the doc passes the hard lint rules.`:`Download this FlowDoc`,onClick:()=>{if(n!==null)try{fd(n)}catch(e){t({type:`error`,message:e instanceof Error?e.message:String(e)})}},children:`Export`}),(0,Y.jsx)(`button`,{type:`button`,className:`rounded border border-neutral-300 px-2 py-1 text-xs hover:bg-neutral-100 disabled:opacity-40 dark:border-neutral-600 dark:hover:bg-neutral-800`,"data-testid":`export-targets-button`,disabled:n===null||y,title:y?`Export is a save: it is disabled until the doc passes the hard lint rules.`:`Export this flow set as CDK, Terraform, or materialized JSON`,onClick:()=>f(!0),children:`Export as…`}),d&&(0,Y.jsx)(Gd,{onClose:()=>f(!1)}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[!p&&(0,Y.jsx)(`button`,{type:`button`,"data-testid":`save-button`,className:`rounded bg-blue-600 px-3 py-1 text-xs font-medium text-white hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-40`,disabled:n===null||y||!o,onClick:()=>void x(),children:`Save`}),e.conflict!==null&&(0,Y.jsx)(`span`,{"data-testid":`save-conflicted`,className:`max-w-64 truncate text-xs text-red-600 dark:text-red-400`,title:e.conflict.reason,children:`Save disabled: choose which side of the conflict wins`}),c&&!s&&e.conflict===null&&v.length===0&&(0,Y.jsx)(`span`,{"data-testid":`save-pending`,className:`text-xs text-neutral-500`,children:`Checking…`}),!s&&v.length>0&&(0,Y.jsxs)(`span`,{"data-testid":`save-invalid`,className:`max-w-64 truncate text-xs text-red-600 dark:text-red-400`,title:v.join(`
21
+ `),children:[m,` disabled: `,v[0]]}),s&&(0,Y.jsxs)(`span`,{"data-testid":`save-blocked`,className:`max-w-64 truncate text-xs text-red-600 dark:text-red-400`,title:_.map(e=>`${e.rule}: ${e.message}`).join(`
22
+ `),children:[m,` disabled: `,_[0]?.rule??`hard lint rule`,` failing`]})]}),e.error!==null&&(0,Y.jsx)(`span`,{role:`alert`,className:`max-w-96 text-xs break-words text-red-600 dark:text-red-400`,title:e.error,children:e.error})]})}var Zd=200;function Qd(e){let t=e.split(`
23
+ `).find(e=>e.trim()!==``)?.trim()??e.trim();return t.length>Zd?`${t.slice(0,199)}…`:t}function $d(e,t){(0,g.useEffect)(()=>{if(e instanceof nl)return e.subscribe(e=>{switch(e.kind){case`synced`:try{t({type:`doc-synced`,name:e.name,doc:zc(e.text)})}catch(n){t({type:`error`,message:`${e.name}: ${n instanceof Error?n.message:String(n)}`})}return;case`conflict`:t({type:`conflict`,conflict:e});return;case`error`:t({type:`sync-error`,...e.name===void 0?{}:{name:e.name},path:e.path,message:Qd(e.message)});return}},e=>{t({type:`notice`,message:`Lost contact with flow-cli studio: ${e}`})})},[e,t])}function ef(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`&&t.content!==null&&typeof t.content==`object`&&Array.isArray(t.content.Actions)}function tf(e){let t=typeof e==`object`&&e&&typeof e.seq==`number`?e.seq:-1,n=e?.doc;if(!ef(n))return{seq:t,findings:[],blocked:!0,error:`Malformed lint request: no FlowDoc.`};try{let e=ds(n);return{seq:t,findings:e,blocked:fs(e)}}catch(e){return{seq:t,findings:[],blocked:!0,error:`Lint failed: ${e instanceof Error?e.message:String(e)}`}}}var nf=4e3;function rf(e,t){let n=(0,g.useRef)(null),r=(0,g.useRef)(!1),i=(0,g.useRef)(0),a=(0,g.useRef)(e);a.current=e,(0,g.useEffect)(()=>()=>{n.current?.terminate(),n.current=null,r.current=!1},[]),(0,g.useEffect)(()=>{if(e===null)return;let o=++i.current,s=!1,c,l=e=>{e.seq===i.current&&(s=!0,c!==void 0&&clearTimeout(c),t({type:`lint`,findings:e.findings,blocked:e.blocked}),e.error!==void 0&&t({type:`error`,message:e.error}))},u=setTimeout(()=>{if(!r.current){r.current=!0;try{let e=new Worker(new URL(`/assets/lint.worker-CsplfZLi.js`,``+import.meta.url),{type:`module`});e.onmessage=e=>l(e.data),e.onerror=()=>{e.terminate(),n.current=null;let t=a.current;t!==null&&l(tf({seq:i.current,doc:t}))},n.current=e}catch{n.current=null}}n.current===null?l(tf({seq:o,doc:e})):(n.current.postMessage({seq:o,doc:e}),c=setTimeout(()=>{s||o!==i.current||(n.current?.terminate(),n.current=null,l(tf({seq:o,doc:e})))},nf))},200);return()=>{clearTimeout(u),c!==void 0&&clearTimeout(c)}},[e,t])}function af(){let{state:e,dispatch:t}=X();return rf(e.doc,t),$d(e.store,t),(0,Y.jsxs)(`div`,{className:`flex h-screen flex-col bg-white text-neutral-900 dark:bg-neutral-950 dark:text-neutral-100`,children:[(0,Y.jsx)(Xd,{}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex w-52 shrink-0 flex-col border-r border-neutral-200 dark:border-neutral-700`,children:[(0,Y.jsx)(mu,{}),(0,Y.jsx)(_u,{})]}),(0,Y.jsxs)(`main`,{className:`relative flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(Ml,{}),(0,Y.jsx)(fu,{}),(0,Y.jsx)(Ul,{}),(0,Y.jsx)(uu,{}),(0,Y.jsx)(Hl,{})]}),(0,Y.jsx)(lu,{})]})]})}function of({store:e}={}){return(0,Y.jsx)(Wl,{children:(0,Y.jsx)(yl,{store:e,children:(0,Y.jsx)(af,{})})})}var sf=document.getElementById(`root`);if(!sf)throw Error(`missing #root`);(0,_.createRoot)(sf).render((0,Y.jsx)(g.StrictMode,{children:(0,Y.jsx)(of,{})}));