@banou/stub 0.0.19 → 0.0.21

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.
Files changed (67) hide show
  1. package/build/.well-known/fkn.json +1 -1
  2. package/build/assets/embed-VjpeLPHx.js +1461 -0
  3. package/build/assets/index-Cq0deG16.js +1964 -0
  4. package/build/assets/lib-DHuurgWT.js +71 -0
  5. package/build/assets/{lib-account-BuVN6Bsx.js → lib-account-B_rZrj_U.js} +1 -1
  6. package/build/assets/lib-account-ZA7I4UZl.js +2 -0
  7. package/build/assets/lib-api-0oE17Lze.js +2 -0
  8. package/build/assets/{lib-build-DEOZ3A7n.js → lib-api-DLvscoll-INenJIDp.js} +863 -556
  9. package/build/assets/lib-worker-B7p9HUJX.js +2 -0
  10. package/build/assets/lib-worker-C6VkH7Kf.js +9006 -0
  11. package/build/assets/lib-worker-index-DCktGn3b.js +1964 -0
  12. package/build/assets/main-DZ0Ws1xk.css +1 -0
  13. package/build/assets/main-JLaHac0l.js +3844 -0
  14. package/build/assets/uri-CY1i0hlC.js +1 -0
  15. package/build/assets/worker-CaEIruuB.js +1 -0
  16. package/build/assets/worker-juGKbgx7.js +1 -0
  17. package/build/embed.html +4 -8
  18. package/build/fkn.json +1 -1
  19. package/build/index.html +5 -8
  20. package/build/index.js +23838 -35935
  21. package/fkn.json +1 -1
  22. package/package.json +6 -3
  23. package/build/assets/Preview-DG9nqCV0.js +0 -1
  24. package/build/assets/compat-CusyxzKh.js +0 -1
  25. package/build/assets/custom-media-element-BDICDseJ.js +0 -43
  26. package/build/assets/dash.all.min-Dbg8AB-J.js +0 -19
  27. package/build/assets/dist-BgIerfpp.js +0 -3136
  28. package/build/assets/dist-BrpV89uJ.js +0 -1
  29. package/build/assets/dist-D-OKiX-f.js +0 -1
  30. package/build/assets/dist-D_XB-JLn.js +0 -40
  31. package/build/assets/embed-DBjG5JMH.js +0 -1
  32. package/build/assets/index-BHgdalnH.js +0 -1401
  33. package/build/assets/lib-Preview-B6uZKyhl.js +0 -82
  34. package/build/assets/lib-account-Cw8yCZtf.js +0 -2
  35. package/build/assets/lib-api-DLvscoll-DhlBp9Wz.js +0 -312
  36. package/build/assets/lib-api-DVwR-22s.js +0 -2
  37. package/build/assets/lib-compat-D8G4_Lzi.js +0 -860
  38. package/build/assets/lib-custom-media-element-CnANKrGl.js +0 -217
  39. package/build/assets/lib-dash.all.min-CDvdorbj.js +0 -27251
  40. package/build/assets/lib-dist-Dv8d3Kr0.js +0 -7
  41. package/build/assets/lib-dist-S8Gxnnq-.js +0 -12468
  42. package/build/assets/lib-dist-T0QlKbbk.js +0 -18578
  43. package/build/assets/lib-dist-xBHT3Lfz.js +0 -911
  44. package/build/assets/lib-react-BEg4mBBK.js +0 -112
  45. package/build/assets/lib-react-C0OCUIWX.js +0 -434
  46. package/build/assets/lib-react-CAkOlDha.js +0 -367
  47. package/build/assets/lib-react-CGlZXIjl.js +0 -2187
  48. package/build/assets/lib-react-CLVoi_ZM.js +0 -334
  49. package/build/assets/lib-react-DUxKSzCt.js +0 -311
  50. package/build/assets/lib-react-QvmpnEVK.js +0 -334
  51. package/build/assets/lib-react-WTnxAo6F.js +0 -202
  52. package/build/assets/lib-remote-DeY2A2G7.js +0 -416
  53. package/build/assets/lib-remote-DxEZmpd0.js +0 -2
  54. package/build/assets/lib-worker-index-C7ynIZYg.js +0 -1401
  55. package/build/assets/main-q4eQ72Te.js +0 -3349
  56. package/build/assets/players-BIbP12aF.js +0 -1530
  57. package/build/assets/preload-helper-D2XUqLHy.js +0 -1
  58. package/build/assets/react-BDr8Ag8b.js +0 -19
  59. package/build/assets/react-BTju4bmn.js +0 -22
  60. package/build/assets/react-CLMfdUXR.js +0 -2
  61. package/build/assets/react-CjmRCHoG.js +0 -34
  62. package/build/assets/react-Cs34a503.js +0 -19
  63. package/build/assets/react-DKSDz1wJ.js +0 -6
  64. package/build/assets/react-bkM_mQGd.js +0 -17
  65. package/build/assets/react-kPj0f67l.js +0 -21
  66. package/build/assets/rolldown-runtime-CNC7AqOf.js +0 -1
  67. /package/build/assets/{players-3a7RYKgR.css → embed-3a7RYKgR.css} +0 -0
@@ -0,0 +1,1964 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);const f=Object.freeze({major:16,minor:11,patch:0,preReleaseTag:null});function p(e,t){if(!e)throw Error(t)}function m(e){return typeof e==`object`&&!!e}function h(e,t){if(!e)throw Error(t??`Unexpected invariant triggered.`)}const g=/\r\n|[\n\r]/g;function _(e,t){let n=0,r=1;for(let i of e.body.matchAll(g)){if(typeof i.index==`number`||h(!1),i.index>=t)break;n=i.index+i[0].length,r+=1}return{line:r,column:t+1-n}}function v(e){return y(e.source,_(e.source,e.start))}function y(e,t){let n=e.locationOffset.column-1,r=``.padStart(n)+e.body,i=t.line-1,a=e.locationOffset.line-1,o=t.line+a,s=t.line===1?n:0,c=t.column+s,l=`${e.name}:${o}:${c}\n`,u=r.split(/\r\n|[\n\r]/g),d=u[i];if(d.length>120){let e=Math.floor(c/80),t=c%80,n=[];for(let e=0;e<d.length;e+=80)n.push(d.slice(e,e+80));return l+b([[`${o} |`,n[0]],...n.slice(1,e+1).map(e=>[`|`,e]),[`|`,`^`.padStart(t)],[`|`,n[e+1]]])}return l+b([[`${o-1} |`,u[i-1]],[`${o} |`,d],[`|`,`^`.padStart(c)],[`${o+1} |`,u[i+1]]])}function b(e){let t=e.filter(([e,t])=>t!==void 0),n=Math.max(...t.map(([e])=>e.length));return t.map(([e,t])=>e.padStart(n)+(t?` `+t:``)).join(`
2
+ `)}function x(e){let t=e[0];return t==null||`kind`in t||`length`in t?{nodes:t,source:e[1],positions:e[2],path:e[3],originalError:e[4],extensions:e[5]}:t}var S=class e extends Error{constructor(t,...n){let{nodes:r,source:i,positions:a,path:o,originalError:s,extensions:c}=x(n);super(t),this.name=`GraphQLError`,this.path=o??void 0,this.originalError=s??void 0,this.nodes=C(Array.isArray(r)?r:r?[r]:void 0);let l=C(this.nodes?.map(e=>e.loc).filter(e=>e!=null));this.source=i??l?.[0]?.source,this.positions=a??l?.map(e=>e.start),this.locations=a&&i?a.map(e=>_(i,e)):l?.map(e=>_(e.source,e.start));let u=m(s?.extensions)?s?.extensions:void 0;this.extensions=c??u??Object.create(null),Object.defineProperties(this,{message:{writable:!0,enumerable:!0},name:{enumerable:!1},nodes:{enumerable:!1},source:{enumerable:!1},positions:{enumerable:!1},originalError:{enumerable:!1}}),s!=null&&s.stack?Object.defineProperty(this,"stack",{value:s.stack,writable:!0,configurable:!0}):Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:Error().stack,writable:!0,configurable:!0})}get[Symbol.toStringTag](){return`GraphQLError`}toString(){let e=this.message;if(this.nodes)for(let t of this.nodes)t.loc&&(e+=`
3
+
4
+ `+v(t.loc));else if(this.source&&this.locations)for(let t of this.locations)e+=`
5
+
6
+ `+y(this.source,t);return e}toJSON(){let e={message:this.message};return this.locations!=null&&(e.locations=this.locations),this.path!=null&&(e.path=this.path),this.extensions!=null&&Object.keys(this.extensions).length>0&&(e.extensions=this.extensions),e}};function C(e){return e===void 0||e.length===0?void 0:e}function w(e,t,n){return new S(`Syntax Error: ${n}`,{source:e,positions:[t]})}var ee=class{constructor(e,t,n){this.start=e.start,this.end=t.end,this.startToken=e,this.endToken=t,this.source=n}get[Symbol.toStringTag](){return`Location`}toJSON(){return{start:this.start,end:this.end}}},te=class{constructor(e,t,n,r,i,a){this.kind=e,this.start=t,this.end=n,this.line=r,this.column=i,this.value=a,this.prev=null,this.next=null}get[Symbol.toStringTag](){return`Token`}toJSON(){return{kind:this.kind,value:this.value,line:this.line,column:this.column}}};const ne={Name:[],Document:[`definitions`],OperationDefinition:[`name`,`variableDefinitions`,`directives`,`selectionSet`],VariableDefinition:[`variable`,`type`,`defaultValue`,`directives`],Variable:[`name`],SelectionSet:[`selections`],Field:[`alias`,`name`,`arguments`,`directives`,`selectionSet`],Argument:[`name`,`value`],FragmentSpread:[`name`,`directives`],InlineFragment:[`typeCondition`,`directives`,`selectionSet`],FragmentDefinition:[`name`,`variableDefinitions`,`typeCondition`,`directives`,`selectionSet`],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:[`values`],ObjectValue:[`fields`],ObjectField:[`name`,`value`],Directive:[`name`,`arguments`],NamedType:[`name`],ListType:[`type`],NonNullType:[`type`],SchemaDefinition:[`description`,`directives`,`operationTypes`],OperationTypeDefinition:[`type`],ScalarTypeDefinition:[`description`,`name`,`directives`],ObjectTypeDefinition:[`description`,`name`,`interfaces`,`directives`,`fields`],FieldDefinition:[`description`,`name`,`arguments`,`type`,`directives`],InputValueDefinition:[`description`,`name`,`type`,`defaultValue`,`directives`],InterfaceTypeDefinition:[`description`,`name`,`interfaces`,`directives`,`fields`],UnionTypeDefinition:[`description`,`name`,`directives`,`types`],EnumTypeDefinition:[`description`,`name`,`directives`,`values`],EnumValueDefinition:[`description`,`name`,`directives`],InputObjectTypeDefinition:[`description`,`name`,`directives`,`fields`],DirectiveDefinition:[`description`,`name`,`arguments`,`locations`],SchemaExtension:[`directives`,`operationTypes`],ScalarTypeExtension:[`name`,`directives`],ObjectTypeExtension:[`name`,`interfaces`,`directives`,`fields`],InterfaceTypeExtension:[`name`,`interfaces`,`directives`,`fields`],UnionTypeExtension:[`name`,`directives`,`types`],EnumTypeExtension:[`name`,`directives`,`values`],InputObjectTypeExtension:[`name`,`directives`,`fields`]},re=new Set(Object.keys(ne));function ie(e){let t=e?.kind;return typeof t==`string`&&re.has(t)}var ae;(function(e){e.QUERY=`query`,e.MUTATION=`mutation`,e.SUBSCRIPTION=`subscription`})(ae||={});var T;(function(e){e.QUERY=`QUERY`,e.MUTATION=`MUTATION`,e.SUBSCRIPTION=`SUBSCRIPTION`,e.FIELD=`FIELD`,e.FRAGMENT_DEFINITION=`FRAGMENT_DEFINITION`,e.FRAGMENT_SPREAD=`FRAGMENT_SPREAD`,e.INLINE_FRAGMENT=`INLINE_FRAGMENT`,e.VARIABLE_DEFINITION=`VARIABLE_DEFINITION`,e.SCHEMA=`SCHEMA`,e.SCALAR=`SCALAR`,e.OBJECT=`OBJECT`,e.FIELD_DEFINITION=`FIELD_DEFINITION`,e.ARGUMENT_DEFINITION=`ARGUMENT_DEFINITION`,e.INTERFACE=`INTERFACE`,e.UNION=`UNION`,e.ENUM=`ENUM`,e.ENUM_VALUE=`ENUM_VALUE`,e.INPUT_OBJECT=`INPUT_OBJECT`,e.INPUT_FIELD_DEFINITION=`INPUT_FIELD_DEFINITION`})(T||={});var E;(function(e){e.NAME=`Name`,e.DOCUMENT=`Document`,e.OPERATION_DEFINITION=`OperationDefinition`,e.VARIABLE_DEFINITION=`VariableDefinition`,e.SELECTION_SET=`SelectionSet`,e.FIELD=`Field`,e.ARGUMENT=`Argument`,e.FRAGMENT_SPREAD=`FragmentSpread`,e.INLINE_FRAGMENT=`InlineFragment`,e.FRAGMENT_DEFINITION=`FragmentDefinition`,e.VARIABLE=`Variable`,e.INT=`IntValue`,e.FLOAT=`FloatValue`,e.STRING=`StringValue`,e.BOOLEAN=`BooleanValue`,e.NULL=`NullValue`,e.ENUM=`EnumValue`,e.LIST=`ListValue`,e.OBJECT=`ObjectValue`,e.OBJECT_FIELD=`ObjectField`,e.DIRECTIVE=`Directive`,e.NAMED_TYPE=`NamedType`,e.LIST_TYPE=`ListType`,e.NON_NULL_TYPE=`NonNullType`,e.SCHEMA_DEFINITION=`SchemaDefinition`,e.OPERATION_TYPE_DEFINITION=`OperationTypeDefinition`,e.SCALAR_TYPE_DEFINITION=`ScalarTypeDefinition`,e.OBJECT_TYPE_DEFINITION=`ObjectTypeDefinition`,e.FIELD_DEFINITION=`FieldDefinition`,e.INPUT_VALUE_DEFINITION=`InputValueDefinition`,e.INTERFACE_TYPE_DEFINITION=`InterfaceTypeDefinition`,e.UNION_TYPE_DEFINITION=`UnionTypeDefinition`,e.ENUM_TYPE_DEFINITION=`EnumTypeDefinition`,e.ENUM_VALUE_DEFINITION=`EnumValueDefinition`,e.INPUT_OBJECT_TYPE_DEFINITION=`InputObjectTypeDefinition`,e.DIRECTIVE_DEFINITION=`DirectiveDefinition`,e.SCHEMA_EXTENSION=`SchemaExtension`,e.SCALAR_TYPE_EXTENSION=`ScalarTypeExtension`,e.OBJECT_TYPE_EXTENSION=`ObjectTypeExtension`,e.INTERFACE_TYPE_EXTENSION=`InterfaceTypeExtension`,e.UNION_TYPE_EXTENSION=`UnionTypeExtension`,e.ENUM_TYPE_EXTENSION=`EnumTypeExtension`,e.INPUT_OBJECT_TYPE_EXTENSION=`InputObjectTypeExtension`})(E||={});function oe(e){return e===9||e===32}function se(e){return e>=48&&e<=57}function ce(e){return e>=97&&e<=122||e>=65&&e<=90}function le(e){return ce(e)||e===95}function ue(e){return ce(e)||se(e)||e===95}function de(e){let t=2**53-1,n=null,r=-1;for(let i=0;i<e.length;++i){let a=e[i],o=fe(a);o!==a.length&&(n??=i,r=i,i!==0&&o<t&&(t=o))}return e.map((e,n)=>n===0?e:e.slice(t)).slice(n??0,r+1)}function fe(e){let t=0;for(;t<e.length&&oe(e.charCodeAt(t));)++t;return t}function pe(e,t){let n=e.replace(/"""/g,`\\"""`),r=n.split(/\r\n|[\n\r]/g),i=r.length===1,a=r.length>1&&r.slice(1).every(e=>e.length===0||oe(e.charCodeAt(0))),o=n.endsWith(`\\"""`),s=e.endsWith(`"`)&&!o,c=e.endsWith(`\\`),l=s||c,u=!(t!=null&&t.minimize)&&(!i||e.length>70||l||a||o),d=``,f=i&&oe(e.charCodeAt(0));return(u&&!f||a)&&(d+=`
7
+ `),d+=n,(u||l)&&(d+=`
8
+ `),`"""`+d+`"""`}var D;(function(e){e.SOF=`<SOF>`,e.EOF=`<EOF>`,e.BANG=`!`,e.DOLLAR=`$`,e.AMP=`&`,e.PAREN_L=`(`,e.PAREN_R=`)`,e.SPREAD=`...`,e.COLON=`:`,e.EQUALS=`=`,e.AT=`@`,e.BRACKET_L=`[`,e.BRACKET_R=`]`,e.BRACE_L=`{`,e.PIPE=`|`,e.BRACE_R=`}`,e.NAME=`Name`,e.INT=`Int`,e.FLOAT=`Float`,e.STRING=`String`,e.BLOCK_STRING=`BlockString`,e.COMMENT=`Comment`})(D||={});var me=class{constructor(e){let t=new te(D.SOF,0,0,0,0);this.source=e,this.lastToken=t,this.token=t,this.line=1,this.lineStart=0}get[Symbol.toStringTag](){return`Lexer`}advance(){return this.lastToken=this.token,this.token=this.lookahead()}lookahead(){let e=this.token;if(e.kind!==D.EOF)do if(e.next)e=e.next;else{let t=xe(this,e.end);e.next=t,t.prev=e,e=t}while(e.kind===D.COMMENT);return e}};function he(e){return e===D.BANG||e===D.DOLLAR||e===D.AMP||e===D.PAREN_L||e===D.PAREN_R||e===D.SPREAD||e===D.COLON||e===D.EQUALS||e===D.AT||e===D.BRACKET_L||e===D.BRACKET_R||e===D.BRACE_L||e===D.PIPE||e===D.BRACE_R}function ge(e){return e>=0&&e<=55295||e>=57344&&e<=1114111}function _e(e,t){return ve(e.charCodeAt(t))&&ye(e.charCodeAt(t+1))}function ve(e){return e>=55296&&e<=56319}function ye(e){return e>=56320&&e<=57343}function be(e,t){let n=e.source.body.codePointAt(t);if(n===void 0)return D.EOF;if(n>=32&&n<=126){let e=String.fromCodePoint(n);return e===`"`?`'"'`:`"${e}"`}return`U+`+n.toString(16).toUpperCase().padStart(4,`0`)}function O(e,t,n,r,i){let a=e.line;return new te(t,n,r,a,1+n-e.lineStart,i)}function xe(e,t){let n=e.source.body,r=n.length,i=t;for(;i<r;){let t=n.charCodeAt(i);switch(t){case 65279:case 9:case 32:case 44:++i;continue;case 10:++i,++e.line,e.lineStart=i;continue;case 13:n.charCodeAt(i+1)===10?i+=2:++i,++e.line,e.lineStart=i;continue;case 35:return Se(e,i);case 33:return O(e,D.BANG,i,i+1);case 36:return O(e,D.DOLLAR,i,i+1);case 38:return O(e,D.AMP,i,i+1);case 40:return O(e,D.PAREN_L,i,i+1);case 41:return O(e,D.PAREN_R,i,i+1);case 46:if(n.charCodeAt(i+1)===46&&n.charCodeAt(i+2)===46)return O(e,D.SPREAD,i,i+3);break;case 58:return O(e,D.COLON,i,i+1);case 61:return O(e,D.EQUALS,i,i+1);case 64:return O(e,D.AT,i,i+1);case 91:return O(e,D.BRACKET_L,i,i+1);case 93:return O(e,D.BRACKET_R,i,i+1);case 123:return O(e,D.BRACE_L,i,i+1);case 124:return O(e,D.PIPE,i,i+1);case 125:return O(e,D.BRACE_R,i,i+1);case 34:return n.charCodeAt(i+1)===34&&n.charCodeAt(i+2)===34?je(e,i):Te(e,i)}if(se(t)||t===45)return Ce(e,i,t);if(le(t))return Me(e,i);throw w(e.source,i,t===39?`Unexpected single quote character ('), did you mean to use a double quote (")?`:ge(t)||_e(n,i)?`Unexpected character: ${be(e,i)}.`:`Invalid character: ${be(e,i)}.`)}return O(e,D.EOF,r,r)}function Se(e,t){let n=e.source.body,r=n.length,i=t+1;for(;i<r;){let e=n.charCodeAt(i);if(e===10||e===13)break;if(ge(e))++i;else if(_e(n,i))i+=2;else break}return O(e,D.COMMENT,t,i,n.slice(t+1,i))}function Ce(e,t,n){let r=e.source.body,i=t,a=n,o=!1;if(a===45&&(a=r.charCodeAt(++i)),a===48){if(a=r.charCodeAt(++i),se(a))throw w(e.source,i,`Invalid number, unexpected digit after 0: ${be(e,i)}.`)}else i=we(e,i,a),a=r.charCodeAt(i);if(a===46&&(o=!0,a=r.charCodeAt(++i),i=we(e,i,a),a=r.charCodeAt(i)),(a===69||a===101)&&(o=!0,a=r.charCodeAt(++i),(a===43||a===45)&&(a=r.charCodeAt(++i)),i=we(e,i,a),a=r.charCodeAt(i)),a===46||le(a))throw w(e.source,i,`Invalid number, expected digit but got: ${be(e,i)}.`);return O(e,o?D.FLOAT:D.INT,t,i,r.slice(t,i))}function we(e,t,n){if(!se(n))throw w(e.source,t,`Invalid number, expected digit but got: ${be(e,t)}.`);let r=e.source.body,i=t+1;for(;se(r.charCodeAt(i));)++i;return i}function Te(e,t){let n=e.source.body,r=n.length,i=t+1,a=i,o=``;for(;i<r;){let r=n.charCodeAt(i);if(r===34)return o+=n.slice(a,i),O(e,D.STRING,t,i+1,o);if(r===92){o+=n.slice(a,i);let t=n.charCodeAt(i+1)===117?n.charCodeAt(i+2)===123?Ee(e,i):De(e,i):Ae(e,i);o+=t.value,i+=t.size,a=i;continue}if(r===10||r===13)break;if(ge(r))++i;else if(_e(n,i))i+=2;else throw w(e.source,i,`Invalid character within String: ${be(e,i)}.`)}throw w(e.source,i,`Unterminated string.`)}function Ee(e,t){let n=e.source.body,r=0,i=3;for(;i<12;){let e=n.charCodeAt(t+i++);if(e===125){if(i<5||!ge(r))break;return{value:String.fromCodePoint(r),size:i}}if(r=r<<4|ke(e),r<0)break}throw w(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+i)}".`)}function De(e,t){let n=e.source.body,r=Oe(n,t+2);if(ge(r))return{value:String.fromCodePoint(r),size:6};if(ve(r)&&n.charCodeAt(t+6)===92&&n.charCodeAt(t+7)===117){let e=Oe(n,t+8);if(ye(e))return{value:String.fromCodePoint(r,e),size:12}}throw w(e.source,t,`Invalid Unicode escape sequence: "${n.slice(t,t+6)}".`)}function Oe(e,t){return ke(e.charCodeAt(t))<<12|ke(e.charCodeAt(t+1))<<8|ke(e.charCodeAt(t+2))<<4|ke(e.charCodeAt(t+3))}function ke(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:-1}function Ae(e,t){let n=e.source.body;switch(n.charCodeAt(t+1)){case 34:return{value:`"`,size:2};case 92:return{value:`\\`,size:2};case 47:return{value:`/`,size:2};case 98:return{value:`\b`,size:2};case 102:return{value:`\f`,size:2};case 110:return{value:`
9
+ `,size:2};case 114:return{value:`\r`,size:2};case 116:return{value:` `,size:2}}throw w(e.source,t,`Invalid character escape sequence: "${n.slice(t,t+2)}".`)}function je(e,t){let n=e.source.body,r=n.length,i=e.lineStart,a=t+3,o=a,s=``,c=[];for(;a<r;){let r=n.charCodeAt(a);if(r===34&&n.charCodeAt(a+1)===34&&n.charCodeAt(a+2)===34){s+=n.slice(o,a),c.push(s);let r=O(e,D.BLOCK_STRING,t,a+3,de(c).join(`
10
+ `));return e.line+=c.length-1,e.lineStart=i,r}if(r===92&&n.charCodeAt(a+1)===34&&n.charCodeAt(a+2)===34&&n.charCodeAt(a+3)===34){s+=n.slice(o,a),o=a+1,a+=4;continue}if(r===10||r===13){s+=n.slice(o,a),c.push(s),r===13&&n.charCodeAt(a+1)===10?a+=2:++a,s=``,o=a,i=a;continue}if(ge(r))++a;else if(_e(n,a))a+=2;else throw w(e.source,a,`Invalid character within String: ${be(e,a)}.`)}throw w(e.source,a,`Unterminated string.`)}function Me(e,t){let n=e.source.body,r=n.length,i=t+1;for(;i<r&&ue(n.charCodeAt(i));)++i;return O(e,D.NAME,t,i,n.slice(t,i))}function k(e){return Ne(e,[])}function Ne(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`function`:return e.name?`[function ${e.name}]`:`[function]`;case`object`:return Pe(e,t);default:return String(e)}}function Pe(e,t){if(e===null)return`null`;if(t.includes(e))return`[Circular]`;let n=[...t,e];if(Fe(e)){let t=e.toJSON();if(t!==e)return typeof t==`string`?t:Ne(t,n)}else if(Array.isArray(e))return Le(e,n);return Ie(e,n)}function Fe(e){return typeof e.toJSON==`function`}function Ie(e,t){let n=Object.entries(e);return n.length===0?`{}`:t.length>2?`[`+Re(e)+`]`:`{ `+n.map(([e,n])=>e+`: `+Ne(n,t)).join(`, `)+` }`}function Le(e,t){if(e.length===0)return`[]`;if(t.length>2)return`[Array]`;let n=Math.min(10,e.length),r=e.length-n,i=[];for(let r=0;r<n;++r)i.push(Ne(e[r],t));return r===1?i.push(`... 1 more item`):r>1&&i.push(`... ${r} more items`),`[`+i.join(`, `)+`]`}function Re(e){let t=Object.prototype.toString.call(e).replace(/^\[object /,``).replace(/]$/,``);if(t===`Object`&&typeof e.constructor==`function`){let t=e.constructor.name;if(typeof t==`string`&&t!==``)return t}return t}const ze=globalThis.process?function(e,t){return e instanceof t}:function(e,t){if(e instanceof t)return!0;if(typeof e==`object`&&e){let n=t.prototype[Symbol.toStringTag];if(n===(Symbol.toStringTag in e?e[Symbol.toStringTag]:e.constructor?.name)){let t=k(e);throw Error(`Cannot use ${n} "${t}" from another module or realm.
11
+
12
+ Ensure that there is only one instance of "graphql" in the node_modules
13
+ directory. If different versions of "graphql" are the dependencies of other
14
+ relied on modules, use "resolutions" to ensure only one version is installed.
15
+
16
+ https://yarnpkg.com/en/docs/selective-version-resolutions
17
+
18
+ Duplicate "graphql" modules cannot be used at the same time since different
19
+ versions may have different capabilities and behavior. The data from one
20
+ version used in the function from another could produce confusing and
21
+ spurious results.`)}}return!1};var Be=class{constructor(e,t=`GraphQL request`,n={line:1,column:1}){typeof e==`string`||p(!1,`Body must be a string. Received: ${k(e)}.`),this.body=e,this.name=t,this.locationOffset=n,this.locationOffset.line>0||p(!1,`line in locationOffset is 1-indexed and must be positive.`),this.locationOffset.column>0||p(!1,`column in locationOffset is 1-indexed and must be positive.`)}get[Symbol.toStringTag](){return`Source`}};function Ve(e){return ze(e,Be)}function He(e,t){let n=new Ue(e,t),r=n.parseDocument();return Object.defineProperty(r,"tokenCount",{enumerable:!1,value:n.tokenCount}),r}var Ue=class{constructor(e,t={}){let n=Ve(e)?e:new Be(e);this._lexer=new me(n),this._options=t,this._tokenCounter=0}get tokenCount(){return this._tokenCounter}parseName(){let e=this.expectToken(D.NAME);return this.node(e,{kind:E.NAME,value:e.value})}parseDocument(){return this.node(this._lexer.token,{kind:E.DOCUMENT,definitions:this.many(D.SOF,this.parseDefinition,D.EOF)})}parseDefinition(){if(this.peek(D.BRACE_L))return this.parseOperationDefinition();let e=this.peekDescription(),t=e?this._lexer.lookahead():this._lexer.token;if(t.kind===D.NAME){switch(t.value){case`schema`:return this.parseSchemaDefinition();case`scalar`:return this.parseScalarTypeDefinition();case`type`:return this.parseObjectTypeDefinition();case`interface`:return this.parseInterfaceTypeDefinition();case`union`:return this.parseUnionTypeDefinition();case`enum`:return this.parseEnumTypeDefinition();case`input`:return this.parseInputObjectTypeDefinition();case`directive`:return this.parseDirectiveDefinition()}if(e)throw w(this._lexer.source,this._lexer.token.start,`Unexpected description, descriptions are supported only on type definitions.`);switch(t.value){case`query`:case`mutation`:case`subscription`:return this.parseOperationDefinition();case`fragment`:return this.parseFragmentDefinition();case`extend`:return this.parseTypeSystemExtension()}}throw this.unexpected(t)}parseOperationDefinition(){let e=this._lexer.token;if(this.peek(D.BRACE_L))return this.node(e,{kind:E.OPERATION_DEFINITION,operation:ae.QUERY,name:void 0,variableDefinitions:[],directives:[],selectionSet:this.parseSelectionSet()});let t=this.parseOperationType(),n;return this.peek(D.NAME)&&(n=this.parseName()),this.node(e,{kind:E.OPERATION_DEFINITION,operation:t,name:n,variableDefinitions:this.parseVariableDefinitions(),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseOperationType(){let e=this.expectToken(D.NAME);switch(e.value){case`query`:return ae.QUERY;case`mutation`:return ae.MUTATION;case`subscription`:return ae.SUBSCRIPTION}throw this.unexpected(e)}parseVariableDefinitions(){return this.optionalMany(D.PAREN_L,this.parseVariableDefinition,D.PAREN_R)}parseVariableDefinition(){return this.node(this._lexer.token,{kind:E.VARIABLE_DEFINITION,variable:this.parseVariable(),type:(this.expectToken(D.COLON),this.parseTypeReference()),defaultValue:this.expectOptionalToken(D.EQUALS)?this.parseConstValueLiteral():void 0,directives:this.parseConstDirectives()})}parseVariable(){let e=this._lexer.token;return this.expectToken(D.DOLLAR),this.node(e,{kind:E.VARIABLE,name:this.parseName()})}parseSelectionSet(){return this.node(this._lexer.token,{kind:E.SELECTION_SET,selections:this.many(D.BRACE_L,this.parseSelection,D.BRACE_R)})}parseSelection(){return this.peek(D.SPREAD)?this.parseFragment():this.parseField()}parseField(){let e=this._lexer.token,t=this.parseName(),n,r;return this.expectOptionalToken(D.COLON)?(n=t,r=this.parseName()):r=t,this.node(e,{kind:E.FIELD,alias:n,name:r,arguments:this.parseArguments(!1),directives:this.parseDirectives(!1),selectionSet:this.peek(D.BRACE_L)?this.parseSelectionSet():void 0})}parseArguments(e){let t=e?this.parseConstArgument:this.parseArgument;return this.optionalMany(D.PAREN_L,t,D.PAREN_R)}parseArgument(e=!1){let t=this._lexer.token,n=this.parseName();return this.expectToken(D.COLON),this.node(t,{kind:E.ARGUMENT,name:n,value:this.parseValueLiteral(e)})}parseConstArgument(){return this.parseArgument(!0)}parseFragment(){let e=this._lexer.token;this.expectToken(D.SPREAD);let t=this.expectOptionalKeyword(`on`);return!t&&this.peek(D.NAME)?this.node(e,{kind:E.FRAGMENT_SPREAD,name:this.parseFragmentName(),directives:this.parseDirectives(!1)}):this.node(e,{kind:E.INLINE_FRAGMENT,typeCondition:t?this.parseNamedType():void 0,directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentDefinition(){let e=this._lexer.token;return this.expectKeyword(`fragment`),this._options.allowLegacyFragmentVariables===!0?this.node(e,{kind:E.FRAGMENT_DEFINITION,name:this.parseFragmentName(),variableDefinitions:this.parseVariableDefinitions(),typeCondition:(this.expectKeyword(`on`),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()}):this.node(e,{kind:E.FRAGMENT_DEFINITION,name:this.parseFragmentName(),typeCondition:(this.expectKeyword(`on`),this.parseNamedType()),directives:this.parseDirectives(!1),selectionSet:this.parseSelectionSet()})}parseFragmentName(){if(this._lexer.token.value===`on`)throw this.unexpected();return this.parseName()}parseValueLiteral(e){let t=this._lexer.token;switch(t.kind){case D.BRACKET_L:return this.parseList(e);case D.BRACE_L:return this.parseObject(e);case D.INT:return this.advanceLexer(),this.node(t,{kind:E.INT,value:t.value});case D.FLOAT:return this.advanceLexer(),this.node(t,{kind:E.FLOAT,value:t.value});case D.STRING:case D.BLOCK_STRING:return this.parseStringLiteral();case D.NAME:switch(this.advanceLexer(),t.value){case`true`:return this.node(t,{kind:E.BOOLEAN,value:!0});case`false`:return this.node(t,{kind:E.BOOLEAN,value:!1});case`null`:return this.node(t,{kind:E.NULL});default:return this.node(t,{kind:E.ENUM,value:t.value})}case D.DOLLAR:if(e)if(this.expectToken(D.DOLLAR),this._lexer.token.kind===D.NAME){let e=this._lexer.token.value;throw w(this._lexer.source,t.start,`Unexpected variable "$${e}" in constant value.`)}else throw this.unexpected(t);return this.parseVariable();default:throw this.unexpected()}}parseConstValueLiteral(){return this.parseValueLiteral(!0)}parseStringLiteral(){let e=this._lexer.token;return this.advanceLexer(),this.node(e,{kind:E.STRING,value:e.value,block:e.kind===D.BLOCK_STRING})}parseList(e){return this.node(this._lexer.token,{kind:E.LIST,values:this.any(D.BRACKET_L,()=>this.parseValueLiteral(e),D.BRACKET_R)})}parseObject(e){return this.node(this._lexer.token,{kind:E.OBJECT,fields:this.any(D.BRACE_L,()=>this.parseObjectField(e),D.BRACE_R)})}parseObjectField(e){let t=this._lexer.token,n=this.parseName();return this.expectToken(D.COLON),this.node(t,{kind:E.OBJECT_FIELD,name:n,value:this.parseValueLiteral(e)})}parseDirectives(e){let t=[];for(;this.peek(D.AT);)t.push(this.parseDirective(e));return t}parseConstDirectives(){return this.parseDirectives(!0)}parseDirective(e){let t=this._lexer.token;return this.expectToken(D.AT),this.node(t,{kind:E.DIRECTIVE,name:this.parseName(),arguments:this.parseArguments(e)})}parseTypeReference(){let e=this._lexer.token,t;if(this.expectOptionalToken(D.BRACKET_L)){let n=this.parseTypeReference();this.expectToken(D.BRACKET_R),t=this.node(e,{kind:E.LIST_TYPE,type:n})}else t=this.parseNamedType();return this.expectOptionalToken(D.BANG)?this.node(e,{kind:E.NON_NULL_TYPE,type:t}):t}parseNamedType(){return this.node(this._lexer.token,{kind:E.NAMED_TYPE,name:this.parseName()})}peekDescription(){return this.peek(D.STRING)||this.peek(D.BLOCK_STRING)}parseDescription(){if(this.peekDescription())return this.parseStringLiteral()}parseSchemaDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`schema`);let n=this.parseConstDirectives(),r=this.many(D.BRACE_L,this.parseOperationTypeDefinition,D.BRACE_R);return this.node(e,{kind:E.SCHEMA_DEFINITION,description:t,directives:n,operationTypes:r})}parseOperationTypeDefinition(){let e=this._lexer.token,t=this.parseOperationType();this.expectToken(D.COLON);let n=this.parseNamedType();return this.node(e,{kind:E.OPERATION_TYPE_DEFINITION,operation:t,type:n})}parseScalarTypeDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`scalar`);let n=this.parseName(),r=this.parseConstDirectives();return this.node(e,{kind:E.SCALAR_TYPE_DEFINITION,description:t,name:n,directives:r})}parseObjectTypeDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`type`);let n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(e,{kind:E.OBJECT_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:a})}parseImplementsInterfaces(){return this.expectOptionalKeyword(`implements`)?this.delimitedMany(D.AMP,this.parseNamedType):[]}parseFieldsDefinition(){return this.optionalMany(D.BRACE_L,this.parseFieldDefinition,D.BRACE_R)}parseFieldDefinition(){let e=this._lexer.token,t=this.parseDescription(),n=this.parseName(),r=this.parseArgumentDefs();this.expectToken(D.COLON);let i=this.parseTypeReference(),a=this.parseConstDirectives();return this.node(e,{kind:E.FIELD_DEFINITION,description:t,name:n,arguments:r,type:i,directives:a})}parseArgumentDefs(){return this.optionalMany(D.PAREN_L,this.parseInputValueDef,D.PAREN_R)}parseInputValueDef(){let e=this._lexer.token,t=this.parseDescription(),n=this.parseName();this.expectToken(D.COLON);let r=this.parseTypeReference(),i;this.expectOptionalToken(D.EQUALS)&&(i=this.parseConstValueLiteral());let a=this.parseConstDirectives();return this.node(e,{kind:E.INPUT_VALUE_DEFINITION,description:t,name:n,type:r,defaultValue:i,directives:a})}parseInterfaceTypeDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`interface`);let n=this.parseName(),r=this.parseImplementsInterfaces(),i=this.parseConstDirectives(),a=this.parseFieldsDefinition();return this.node(e,{kind:E.INTERFACE_TYPE_DEFINITION,description:t,name:n,interfaces:r,directives:i,fields:a})}parseUnionTypeDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`union`);let n=this.parseName(),r=this.parseConstDirectives(),i=this.parseUnionMemberTypes();return this.node(e,{kind:E.UNION_TYPE_DEFINITION,description:t,name:n,directives:r,types:i})}parseUnionMemberTypes(){return this.expectOptionalToken(D.EQUALS)?this.delimitedMany(D.PIPE,this.parseNamedType):[]}parseEnumTypeDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`enum`);let n=this.parseName(),r=this.parseConstDirectives(),i=this.parseEnumValuesDefinition();return this.node(e,{kind:E.ENUM_TYPE_DEFINITION,description:t,name:n,directives:r,values:i})}parseEnumValuesDefinition(){return this.optionalMany(D.BRACE_L,this.parseEnumValueDefinition,D.BRACE_R)}parseEnumValueDefinition(){let e=this._lexer.token,t=this.parseDescription(),n=this.parseEnumValueName(),r=this.parseConstDirectives();return this.node(e,{kind:E.ENUM_VALUE_DEFINITION,description:t,name:n,directives:r})}parseEnumValueName(){if(this._lexer.token.value===`true`||this._lexer.token.value===`false`||this._lexer.token.value===`null`)throw w(this._lexer.source,this._lexer.token.start,`${We(this._lexer.token)} is reserved and cannot be used for an enum value.`);return this.parseName()}parseInputObjectTypeDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`input`);let n=this.parseName(),r=this.parseConstDirectives(),i=this.parseInputFieldsDefinition();return this.node(e,{kind:E.INPUT_OBJECT_TYPE_DEFINITION,description:t,name:n,directives:r,fields:i})}parseInputFieldsDefinition(){return this.optionalMany(D.BRACE_L,this.parseInputValueDef,D.BRACE_R)}parseTypeSystemExtension(){let e=this._lexer.lookahead();if(e.kind===D.NAME)switch(e.value){case`schema`:return this.parseSchemaExtension();case`scalar`:return this.parseScalarTypeExtension();case`type`:return this.parseObjectTypeExtension();case`interface`:return this.parseInterfaceTypeExtension();case`union`:return this.parseUnionTypeExtension();case`enum`:return this.parseEnumTypeExtension();case`input`:return this.parseInputObjectTypeExtension()}throw this.unexpected(e)}parseSchemaExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`schema`);let t=this.parseConstDirectives(),n=this.optionalMany(D.BRACE_L,this.parseOperationTypeDefinition,D.BRACE_R);if(t.length===0&&n.length===0)throw this.unexpected();return this.node(e,{kind:E.SCHEMA_EXTENSION,directives:t,operationTypes:n})}parseScalarTypeExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`scalar`);let t=this.parseName(),n=this.parseConstDirectives();if(n.length===0)throw this.unexpected();return this.node(e,{kind:E.SCALAR_TYPE_EXTENSION,name:t,directives:n})}parseObjectTypeExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`type`);let t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(n.length===0&&r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:E.OBJECT_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseInterfaceTypeExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`interface`);let t=this.parseName(),n=this.parseImplementsInterfaces(),r=this.parseConstDirectives(),i=this.parseFieldsDefinition();if(n.length===0&&r.length===0&&i.length===0)throw this.unexpected();return this.node(e,{kind:E.INTERFACE_TYPE_EXTENSION,name:t,interfaces:n,directives:r,fields:i})}parseUnionTypeExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`union`);let t=this.parseName(),n=this.parseConstDirectives(),r=this.parseUnionMemberTypes();if(n.length===0&&r.length===0)throw this.unexpected();return this.node(e,{kind:E.UNION_TYPE_EXTENSION,name:t,directives:n,types:r})}parseEnumTypeExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`enum`);let t=this.parseName(),n=this.parseConstDirectives(),r=this.parseEnumValuesDefinition();if(n.length===0&&r.length===0)throw this.unexpected();return this.node(e,{kind:E.ENUM_TYPE_EXTENSION,name:t,directives:n,values:r})}parseInputObjectTypeExtension(){let e=this._lexer.token;this.expectKeyword(`extend`),this.expectKeyword(`input`);let t=this.parseName(),n=this.parseConstDirectives(),r=this.parseInputFieldsDefinition();if(n.length===0&&r.length===0)throw this.unexpected();return this.node(e,{kind:E.INPUT_OBJECT_TYPE_EXTENSION,name:t,directives:n,fields:r})}parseDirectiveDefinition(){let e=this._lexer.token,t=this.parseDescription();this.expectKeyword(`directive`),this.expectToken(D.AT);let n=this.parseName(),r=this.parseArgumentDefs(),i=this.expectOptionalKeyword(`repeatable`);this.expectKeyword(`on`);let a=this.parseDirectiveLocations();return this.node(e,{kind:E.DIRECTIVE_DEFINITION,description:t,name:n,arguments:r,repeatable:i,locations:a})}parseDirectiveLocations(){return this.delimitedMany(D.PIPE,this.parseDirectiveLocation)}parseDirectiveLocation(){let e=this._lexer.token,t=this.parseName();if(Object.prototype.hasOwnProperty.call(T,t.value))return t;throw this.unexpected(e)}node(e,t){return this._options.noLocation!==!0&&(t.loc=new ee(e,this._lexer.lastToken,this._lexer.source)),t}peek(e){return this._lexer.token.kind===e}expectToken(e){let t=this._lexer.token;if(t.kind===e)return this.advanceLexer(),t;throw w(this._lexer.source,t.start,`Expected ${Ge(e)}, found ${We(t)}.`)}expectOptionalToken(e){return this._lexer.token.kind===e?(this.advanceLexer(),!0):!1}expectKeyword(e){let t=this._lexer.token;if(t.kind===D.NAME&&t.value===e)this.advanceLexer();else throw w(this._lexer.source,t.start,`Expected "${e}", found ${We(t)}.`)}expectOptionalKeyword(e){let t=this._lexer.token;return t.kind===D.NAME&&t.value===e?(this.advanceLexer(),!0):!1}unexpected(e){let t=e??this._lexer.token;return w(this._lexer.source,t.start,`Unexpected ${We(t)}.`)}any(e,t,n){this.expectToken(e);let r=[];for(;!this.expectOptionalToken(n);)r.push(t.call(this));return r}optionalMany(e,t,n){if(this.expectOptionalToken(e)){let e=[];do e.push(t.call(this));while(!this.expectOptionalToken(n));return e}return[]}many(e,t,n){this.expectToken(e);let r=[];do r.push(t.call(this));while(!this.expectOptionalToken(n));return r}delimitedMany(e,t){this.expectOptionalToken(e);let n=[];do n.push(t.call(this));while(this.expectOptionalToken(e));return n}advanceLexer(){let{maxTokens:e}=this._options,t=this._lexer.advance();if(t.kind!==D.EOF&&(++this._tokenCounter,e!==void 0&&this._tokenCounter>e))throw w(this._lexer.source,t.start,`Document contains more that ${e} tokens. Parsing aborted.`)}};function We(e){let t=e.value;return Ge(e.kind)+(t==null?``:` "${t}"`)}function Ge(e){return he(e)?`"${e}"`:e}function Ke(e,t){let[n,r]=t?[e,t]:[void 0,e],i=` Did you mean `;n&&(i+=n+` `);let a=r.map(e=>`"${e}"`);switch(a.length){case 0:return``;case 1:return i+a[0]+`?`;case 2:return i+a[0]+` or `+a[1]+`?`}let o=a.slice(0,5),s=o.pop();return i+o.join(`, `)+`, or `+s+`?`}function qe(e){return e}function Je(e,t){let n=Object.create(null);for(let r of e)n[t(r)]=r;return n}function Ye(e,t,n){let r=Object.create(null);for(let i of e)r[t(i)]=n(i);return r}function Xe(e,t){let n=Object.create(null);for(let r of Object.keys(e))n[r]=t(e[r],r);return n}function Ze(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),a=t.charCodeAt(r);if($e(i)&&$e(a)){let o=0;do++n,o=o*10+i-Qe,i=e.charCodeAt(n);while($e(i)&&o>0);let s=0;do++r,s=s*10+a-Qe,a=t.charCodeAt(r);while($e(a)&&s>0);if(o<s)return-1;if(o>s)return 1}else{if(i<a)return-1;if(i>a)return 1;++n,++r}}return e.length-t.length}const Qe=48;function $e(e){return!isNaN(e)&&48<=e&&e<=57}function et(e,t){let n=Object.create(null),r=new tt(e),i=Math.floor(e.length*.4)+1;for(let e of t){let t=r.measure(e,i);t!==void 0&&(n[e]=t)}return Object.keys(n).sort((e,t)=>{let r=n[e]-n[t];return r===0?Ze(e,t):r})}var tt=class{constructor(e){this._input=e,this._inputLowerCase=e.toLowerCase(),this._inputArray=nt(this._inputLowerCase),this._rows=[Array(e.length+1).fill(0),Array(e.length+1).fill(0),Array(e.length+1).fill(0)]}measure(e,t){if(this._input===e)return 0;let n=e.toLowerCase();if(this._inputLowerCase===n)return 1;let r=nt(n),i=this._inputArray;if(r.length<i.length){let e=r;r=i,i=e}let a=r.length,o=i.length;if(a-o>t)return;let s=this._rows;for(let e=0;e<=o;e++)s[0][e]=e;for(let e=1;e<=a;e++){let n=s[(e-1)%3],a=s[e%3],c=a[0]=e;for(let t=1;t<=o;t++){let o=r[e-1]===i[t-1]?0:1,l=Math.min(n[t]+1,a[t-1]+1,n[t-1]+o);if(e>1&&t>1&&r[e-1]===i[t-2]&&r[e-2]===i[t-1]){let n=s[(e-2)%3][t-2];l=Math.min(l,n+1)}l<c&&(c=l),a[t]=l}if(c>t)return}let c=s[a%3][o];return c<=t?c:void 0}};function nt(e){let t=e.length,n=Array(t);for(let r=0;r<t;++r)n[r]=e.charCodeAt(r);return n}function rt(e){if(e==null)return Object.create(null);if(Object.getPrototypeOf(e)===null)return e;let t=Object.create(null);for(let[n,r]of Object.entries(e))t[n]=r;return t}function it(e){return`"${e.replace(at,ot)}"`}const at=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function ot(e){return st[e.charCodeAt(0)]}const st=`\\u0000.\\u0001.\\u0002.\\u0003.\\u0004.\\u0005.\\u0006.\\u0007.\\b.\\t.\\n.\\u000B.\\f.\\r.\\u000E.\\u000F.\\u0010.\\u0011.\\u0012.\\u0013.\\u0014.\\u0015.\\u0016.\\u0017.\\u0018.\\u0019.\\u001A.\\u001B.\\u001C.\\u001D.\\u001E.\\u001F...\\"..........................................................\\\\...................................\\u007F.\\u0080.\\u0081.\\u0082.\\u0083.\\u0084.\\u0085.\\u0086.\\u0087.\\u0088.\\u0089.\\u008A.\\u008B.\\u008C.\\u008D.\\u008E.\\u008F.\\u0090.\\u0091.\\u0092.\\u0093.\\u0094.\\u0095.\\u0096.\\u0097.\\u0098.\\u0099.\\u009A.\\u009B.\\u009C.\\u009D.\\u009E.\\u009F`.split(`.`),ct=Object.freeze({});function lt(e,t,n=ne){let r=new Map;for(let e of Object.values(E))r.set(e,dt(t,e));let i,a=Array.isArray(e),o=[e],s=-1,c=[],l=e,u,d,f=[],m=[];do{s++;let e=s===o.length,h=e&&c.length!==0;if(e){if(u=m.length===0?void 0:f[f.length-1],l=d,d=m.pop(),h)if(a){l=l.slice();let e=0;for(let[t,n]of c){let r=t-e;n===null?(l.splice(r,1),e++):l[r]=n}}else{l={...l};for(let[e,t]of c)l[e]=t}s=i.index,o=i.keys,c=i.edits,a=i.inArray,i=i.prev}else if(d){if(u=a?s:o[s],l=d[u],l==null)continue;f.push(u)}let g;if(!Array.isArray(l)){if(ie(l)||p(!1,`Invalid AST Node: ${k(l)}.`),g=(e?r.get(l.kind)?.leave:r.get(l.kind)?.enter)?.call(t,l,u,d,f,m),g===ct)break;if(g===!1){if(!e){f.pop();continue}}else if(g!==void 0&&(c.push([u,g]),!e))if(ie(g))l=g;else{f.pop();continue}}g===void 0&&h&&c.push([u,l]),e?f.pop():(i={inArray:a,index:s,keys:o,edits:c,prev:i},a=Array.isArray(l),o=a?l:n[l.kind]??[],s=-1,c=[],d&&m.push(d),d=l)}while(i!==void 0);return c.length===0?e:c[c.length-1][1]}function ut(e){let t=Array(e.length).fill(null),n=Object.create(null);for(let r of Object.values(E)){let i=!1,a=Array(e.length).fill(void 0),o=Array(e.length).fill(void 0);for(let t=0;t<e.length;++t){let{enter:n,leave:s}=dt(e[t],r);i||=n!=null||s!=null,a[t]=n,o[t]=s}i&&(n[r]={enter(...n){let r=n[0];for(let i=0;i<e.length;i++)if(t[i]===null){let o=a[i]?.apply(e[i],n);if(o===!1)t[i]=r;else if(o===ct)t[i]=ct;else if(o!==void 0)return o}},leave(...n){let r=n[0];for(let i=0;i<e.length;i++)if(t[i]===null){let r=o[i]?.apply(e[i],n);if(r===ct)t[i]=ct;else if(r!==void 0&&r!==!1)return r}else t[i]===r&&(t[i]=null)}})}return n}function dt(e,t){let n=e[t];return typeof n==`object`?n:typeof n==`function`?{enter:n,leave:void 0}:{enter:e.enter,leave:e.leave}}function ft(e){return lt(e,pt)}const pt={Name:{leave:e=>e.value},Variable:{leave:e=>`$`+e.name},Document:{leave:e=>A(e.definitions,`
22
+
23
+ `)},OperationDefinition:{leave(e){let t=ht(`(`,A(e.variableDefinitions,`, `),`)`),n=A([e.operation,A([e.name,t]),A(e.directives,` `)],` `);return(n===`query`?``:n+` `)+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+`: `+t+ht(` = `,n)+ht(` `,A(r,` `))},SelectionSet:{leave:({selections:e})=>mt(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){let a=ht(``,e,`: `)+t,o=a+ht(`(`,A(n,`, `),`)`);return o.length>80&&(o=a+ht(`(
24
+ `,gt(A(n,`
25
+ `)),`
26
+ )`)),A([o,A(r,` `),i],` `)}},Argument:{leave:({name:e,value:t})=>e+`: `+t},FragmentSpread:{leave:({name:e,directives:t})=>`...`+e+ht(` `,A(t,` `))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>A([`...`,ht(`on `,e),A(t,` `),n],` `)},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${ht(`(`,A(n,`, `),`)`)} on ${t} ${ht(``,A(r,` `),` `)}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?pe(e):it(e)},BooleanValue:{leave:({value:e})=>e?`true`:`false`},NullValue:{leave:()=>`null`},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>`[`+A(e,`, `)+`]`},ObjectValue:{leave:({fields:e})=>`{`+A(e,`, `)+`}`},ObjectField:{leave:({name:e,value:t})=>e+`: `+t},Directive:{leave:({name:e,arguments:t})=>`@`+e+ht(`(`,A(t,`, `),`)`)},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>`[`+e+`]`},NonNullType:{leave:({type:e})=>e+`!`},SchemaDefinition:{leave:({description:e,directives:t,operationTypes:n})=>ht(``,e,`
27
+ `)+A([`schema`,A(t,` `),mt(n)],` `)},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+`: `+t},ScalarTypeDefinition:{leave:({description:e,name:t,directives:n})=>ht(``,e,`
28
+ `)+A([`scalar`,t,A(n,` `)],` `)},ObjectTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ht(``,e,`
29
+ `)+A([`type`,t,ht(`implements `,A(n,` & `)),A(r,` `),mt(i)],` `)},FieldDefinition:{leave:({description:e,name:t,arguments:n,type:r,directives:i})=>ht(``,e,`
30
+ `)+t+(_t(n)?ht(`(
31
+ `,gt(A(n,`
32
+ `)),`
33
+ )`):ht(`(`,A(n,`, `),`)`))+`: `+r+ht(` `,A(i,` `))},InputValueDefinition:{leave:({description:e,name:t,type:n,defaultValue:r,directives:i})=>ht(``,e,`
34
+ `)+A([t+`: `+n,ht(`= `,r),A(i,` `)],` `)},InterfaceTypeDefinition:{leave:({description:e,name:t,interfaces:n,directives:r,fields:i})=>ht(``,e,`
35
+ `)+A([`interface`,t,ht(`implements `,A(n,` & `)),A(r,` `),mt(i)],` `)},UnionTypeDefinition:{leave:({description:e,name:t,directives:n,types:r})=>ht(``,e,`
36
+ `)+A([`union`,t,A(n,` `),ht(`= `,A(r,` | `))],` `)},EnumTypeDefinition:{leave:({description:e,name:t,directives:n,values:r})=>ht(``,e,`
37
+ `)+A([`enum`,t,A(n,` `),mt(r)],` `)},EnumValueDefinition:{leave:({description:e,name:t,directives:n})=>ht(``,e,`
38
+ `)+A([t,A(n,` `)],` `)},InputObjectTypeDefinition:{leave:({description:e,name:t,directives:n,fields:r})=>ht(``,e,`
39
+ `)+A([`input`,t,A(n,` `),mt(r)],` `)},DirectiveDefinition:{leave:({description:e,name:t,arguments:n,repeatable:r,locations:i})=>ht(``,e,`
40
+ `)+`directive @`+t+(_t(n)?ht(`(
41
+ `,gt(A(n,`
42
+ `)),`
43
+ )`):ht(`(`,A(n,`, `),`)`))+(r?` repeatable`:``)+` on `+A(i,` | `)},SchemaExtension:{leave:({directives:e,operationTypes:t})=>A([`extend schema`,A(e,` `),mt(t)],` `)},ScalarTypeExtension:{leave:({name:e,directives:t})=>A([`extend scalar`,e,A(t,` `)],` `)},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>A([`extend type`,e,ht(`implements `,A(t,` & `)),A(n,` `),mt(r)],` `)},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>A([`extend interface`,e,ht(`implements `,A(t,` & `)),A(n,` `),mt(r)],` `)},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>A([`extend union`,e,A(t,` `),ht(`= `,A(n,` | `))],` `)},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>A([`extend enum`,e,A(t,` `),mt(n)],` `)},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>A([`extend input`,e,A(t,` `),mt(n)],` `)}};function A(e,t=``){return e?.filter(e=>e).join(t)??``}function mt(e){return ht(`{
44
+ `,gt(A(e,`
45
+ `)),`
46
+ }`)}function ht(e,t,n=``){return t!=null&&t!==``?e+t+n:``}function gt(e){return ht(` `,e.replace(/\n/g,`
47
+ `))}function _t(e){return e?.some(e=>e.includes(`
48
+ `))??!1}function vt(e,t){switch(e.kind){case E.NULL:return null;case E.INT:return parseInt(e.value,10);case E.FLOAT:return parseFloat(e.value);case E.STRING:case E.ENUM:case E.BOOLEAN:return e.value;case E.LIST:return e.values.map(e=>vt(e,t));case E.OBJECT:return Ye(e.fields,e=>e.name.value,e=>vt(e.value,t));case E.VARIABLE:return t?.[e.name.value]}}function yt(e){if(e??p(!1,`Must provide name.`),typeof e==`string`||p(!1,`Expected name to be a string.`),e.length===0)throw new S(`Expected name to be a non-empty string.`);for(let t=1;t<e.length;++t)if(!ue(e.charCodeAt(t)))throw new S(`Names must only contain [_a-zA-Z0-9] but "${e}" does not.`);if(!le(e.charCodeAt(0)))throw new S(`Names must start with [_a-zA-Z] but "${e}" does not.`);return e}function bt(e){if(e===`true`||e===`false`||e===`null`)throw new S(`Enum values cannot be named: ${e}`);return yt(e)}function xt(e){return St(e)||j(e)||Ct(e)||wt(e)||Tt(e)||Et(e)||Dt(e)||M(e)}function St(e){return ze(e,Vt)}function j(e){return ze(e,Ht)}function Ct(e){return ze(e,Xt)}function wt(e){return ze(e,Zt)}function Tt(e){return ze(e,$t)}function Et(e){return ze(e,nn)}function Dt(e){return ze(e,Nt)}function M(e){return ze(e,N)}function Ot(e){return St(e)||Tt(e)||Et(e)||Pt(e)&&Ot(e.ofType)}function kt(e){return St(e)||j(e)||Ct(e)||wt(e)||Tt(e)||Pt(e)&&kt(e.ofType)}function At(e){return St(e)||Tt(e)}function jt(e){return j(e)||Ct(e)||wt(e)}function Mt(e){return Ct(e)||wt(e)}var Nt=class{constructor(e){xt(e)||p(!1,`Expected ${k(e)} to be a GraphQL type.`),this.ofType=e}get[Symbol.toStringTag](){return`GraphQLList`}toString(){return`[`+String(this.ofType)+`]`}toJSON(){return this.toString()}},N=class{constructor(e){Ft(e)||p(!1,`Expected ${k(e)} to be a GraphQL nullable type.`),this.ofType=e}get[Symbol.toStringTag](){return`GraphQLNonNull`}toString(){return String(this.ofType)+`!`}toJSON(){return this.toString()}};function Pt(e){return Dt(e)||M(e)}function Ft(e){return xt(e)&&!M(e)}function It(e){if(e)return M(e)?e.ofType:e}function Lt(e){return St(e)||j(e)||Ct(e)||wt(e)||Tt(e)||Et(e)}function Rt(e){if(e){let t=e;for(;Pt(t);)t=t.ofType;return t}}function zt(e){return typeof e==`function`?e():e}function Bt(e){return typeof e==`function`?e():e}var Vt=class{constructor(e){let t=e.parseValue??qe;this.name=yt(e.name),this.description=e.description,this.specifiedByURL=e.specifiedByURL,this.serialize=e.serialize??qe,this.parseValue=t,this.parseLiteral=e.parseLiteral??((e,n)=>t(vt(e,n))),this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],e.specifiedByURL==null||typeof e.specifiedByURL==`string`||p(!1,`${this.name} must provide "specifiedByURL" as a string, but got: ${k(e.specifiedByURL)}.`),e.serialize==null||typeof e.serialize==`function`||p(!1,`${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`),e.parseLiteral&&(typeof e.parseValue==`function`&&typeof e.parseLiteral==`function`||p(!1,`${this.name} must provide both "parseValue" and "parseLiteral" functions.`))}get[Symbol.toStringTag](){return`GraphQLScalarType`}toConfig(){return{name:this.name,description:this.description,specifiedByURL:this.specifiedByURL,serialize:this.serialize,parseValue:this.parseValue,parseLiteral:this.parseLiteral,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}},Ht=class{constructor(e){this.name=yt(e.name),this.description=e.description,this.isTypeOf=e.isTypeOf,this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],this._fields=()=>Wt(e),this._interfaces=()=>Ut(e),e.isTypeOf==null||typeof e.isTypeOf==`function`||p(!1,`${this.name} must provide "isTypeOf" as a function, but got: ${k(e.isTypeOf)}.`)}get[Symbol.toStringTag](){return`GraphQLObjectType`}getFields(){return typeof this._fields==`function`&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces==`function`&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:qt(this.getFields()),isTypeOf:this.isTypeOf,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}};function Ut(e){let t=zt(e.interfaces??[]);return Array.isArray(t)||p(!1,`${e.name} interfaces must be an Array or a function which returns an Array.`),t}function Wt(e){let t=Bt(e.fields);return Kt(t)||p(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Xe(t,(t,n)=>{Kt(t)||p(!1,`${e.name}.${n} field config must be an object.`),t.resolve==null||typeof t.resolve==`function`||p(!1,`${e.name}.${n} field resolver must be a function if provided, but got: ${k(t.resolve)}.`);let r=t.args??{};return Kt(r)||p(!1,`${e.name}.${n} args must be an object with argument names as keys.`),{name:yt(n),description:t.description,type:t.type,args:Gt(r),resolve:t.resolve,subscribe:t.subscribe,deprecationReason:t.deprecationReason,extensions:rt(t.extensions),astNode:t.astNode}})}function Gt(e){return Object.entries(e).map(([e,t])=>({name:yt(e),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:rt(t.extensions),astNode:t.astNode}))}function Kt(e){return m(e)&&!Array.isArray(e)}function qt(e){return Xe(e,e=>({description:e.description,type:e.type,args:Jt(e.args),resolve:e.resolve,subscribe:e.subscribe,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}))}function Jt(e){return Ye(e,e=>e.name,e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}))}function Yt(e){return M(e.type)&&e.defaultValue===void 0}var Xt=class{constructor(e){this.name=yt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],this._fields=Wt.bind(void 0,e),this._interfaces=Ut.bind(void 0,e),e.resolveType==null||typeof e.resolveType==`function`||p(!1,`${this.name} must provide "resolveType" as a function, but got: ${k(e.resolveType)}.`)}get[Symbol.toStringTag](){return`GraphQLInterfaceType`}getFields(){return typeof this._fields==`function`&&(this._fields=this._fields()),this._fields}getInterfaces(){return typeof this._interfaces==`function`&&(this._interfaces=this._interfaces()),this._interfaces}toConfig(){return{name:this.name,description:this.description,interfaces:this.getInterfaces(),fields:qt(this.getFields()),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}},Zt=class{constructor(e){this.name=yt(e.name),this.description=e.description,this.resolveType=e.resolveType,this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],this._types=Qt.bind(void 0,e),e.resolveType==null||typeof e.resolveType==`function`||p(!1,`${this.name} must provide "resolveType" as a function, but got: ${k(e.resolveType)}.`)}get[Symbol.toStringTag](){return`GraphQLUnionType`}getTypes(){return typeof this._types==`function`&&(this._types=this._types()),this._types}toConfig(){return{name:this.name,description:this.description,types:this.getTypes(),resolveType:this.resolveType,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}};function Qt(e){let t=zt(e.types);return Array.isArray(t)||p(!1,`Must provide Array of types or a function which returns such an array for Union ${e.name}.`),t}var $t=class{constructor(e){this.name=yt(e.name),this.description=e.description,this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],this._values=typeof e.values==`function`?e.values:tn(this.name,e.values),this._valueLookup=null,this._nameLookup=null}get[Symbol.toStringTag](){return`GraphQLEnumType`}getValues(){return typeof this._values==`function`&&(this._values=tn(this.name,this._values())),this._values}getValue(e){return this._nameLookup===null&&(this._nameLookup=Je(this.getValues(),e=>e.name)),this._nameLookup[e]}serialize(e){this._valueLookup===null&&(this._valueLookup=new Map(this.getValues().map(e=>[e.value,e])));let t=this._valueLookup.get(e);if(t===void 0)throw new S(`Enum "${this.name}" cannot represent value: ${k(e)}`);return t.name}parseValue(e){if(typeof e!=`string`){let t=k(e);throw new S(`Enum "${this.name}" cannot represent non-string value: ${t}.`+en(this,t))}let t=this.getValue(e);if(t==null)throw new S(`Value "${e}" does not exist in "${this.name}" enum.`+en(this,e));return t.value}parseLiteral(e,t){if(e.kind!==E.ENUM){let t=ft(e);throw new S(`Enum "${this.name}" cannot represent non-enum value: ${t}.`+en(this,t),{nodes:e})}let n=this.getValue(e.value);if(n==null){let t=ft(e);throw new S(`Value "${t}" does not exist in "${this.name}" enum.`+en(this,t),{nodes:e})}return n.value}toConfig(){let e=Ye(this.getValues(),e=>e.name,e=>({description:e.description,value:e.value,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}));return{name:this.name,description:this.description,values:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes}}toString(){return this.name}toJSON(){return this.toString()}};function en(e,t){return Ke(`the enum value`,et(t,e.getValues().map(e=>e.name)))}function tn(e,t){return Kt(t)||p(!1,`${e} values must be an object with value names as keys.`),Object.entries(t).map(([t,n])=>(Kt(n)||p(!1,`${e}.${t} must refer to an object with a "value" key representing an internal value but got: ${k(n)}.`),{name:bt(t),description:n.description,value:n.value===void 0?t:n.value,deprecationReason:n.deprecationReason,extensions:rt(n.extensions),astNode:n.astNode}))}var nn=class{constructor(e){this.name=yt(e.name),this.description=e.description,this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],this.isOneOf=e.isOneOf??!1,this._fields=rn.bind(void 0,e)}get[Symbol.toStringTag](){return`GraphQLInputObjectType`}getFields(){return typeof this._fields==`function`&&(this._fields=this._fields()),this._fields}toConfig(){let e=Xe(this.getFields(),e=>({description:e.description,type:e.type,defaultValue:e.defaultValue,deprecationReason:e.deprecationReason,extensions:e.extensions,astNode:e.astNode}));return{name:this.name,description:this.description,fields:e,extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,isOneOf:this.isOneOf}}toString(){return this.name}toJSON(){return this.toString()}};function rn(e){let t=Bt(e.fields);return Kt(t)||p(!1,`${e.name} fields must be an object with field names as keys or a function which returns such an object.`),Xe(t,(t,n)=>(!(`resolve`in t)||p(!1,`${e.name}.${n} field has a resolve property, but Input Types cannot define resolvers.`),{name:yt(n),description:t.description,type:t.type,defaultValue:t.defaultValue,deprecationReason:t.deprecationReason,extensions:rt(t.extensions),astNode:t.astNode}))}function an(e){return M(e.type)&&e.defaultValue===void 0}function on(e,t){return e===t?!0:M(e)&&M(t)||Dt(e)&&Dt(t)?on(e.ofType,t.ofType):!1}function sn(e,t,n){return t===n?!0:M(n)?M(t)?sn(e,t.ofType,n.ofType):!1:M(t)?sn(e,t.ofType,n):Dt(n)?Dt(t)?sn(e,t.ofType,n.ofType):!1:Dt(t)?!1:Mt(n)&&(Ct(t)||j(t))&&e.isSubType(n,t)}function cn(e,t,n){return t===n?!0:Mt(t)?Mt(n)?e.getPossibleTypes(t).some(t=>e.isSubType(n,t)):e.isSubType(t,n):Mt(n)?e.isSubType(n,t):!1}const ln=new Vt({name:`Int`,description:"The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",serialize(e){let t=gn(e);if(typeof t==`boolean`)return+!!t;let n=t;if(typeof t==`string`&&t!==``&&(n=Number(t)),typeof n!=`number`||!Number.isInteger(n))throw new S(`Int cannot represent non-integer value: ${k(t)}`);if(n>2147483647||n<-2147483648)throw new S(`Int cannot represent non 32-bit signed integer value: `+k(t));return n},parseValue(e){if(typeof e!=`number`||!Number.isInteger(e))throw new S(`Int cannot represent non-integer value: ${k(e)}`);if(e>2147483647||e<-2147483648)throw new S(`Int cannot represent non 32-bit signed integer value: ${e}`);return e},parseLiteral(e){if(e.kind!==E.INT)throw new S(`Int cannot represent non-integer value: ${ft(e)}`,{nodes:e});let t=parseInt(e.value,10);if(t>2147483647||t<-2147483648)throw new S(`Int cannot represent non 32-bit signed integer value: ${e.value}`,{nodes:e});return t}}),un=new Vt({name:`Float`,description:"The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).",serialize(e){let t=gn(e);if(typeof t==`boolean`)return+!!t;let n=t;if(typeof t==`string`&&t!==``&&(n=Number(t)),typeof n!=`number`||!Number.isFinite(n))throw new S(`Float cannot represent non numeric value: ${k(t)}`);return n},parseValue(e){if(typeof e!=`number`||!Number.isFinite(e))throw new S(`Float cannot represent non numeric value: ${k(e)}`);return e},parseLiteral(e){if(e.kind!==E.FLOAT&&e.kind!==E.INT)throw new S(`Float cannot represent non numeric value: ${ft(e)}`,e);return parseFloat(e.value)}}),dn=new Vt({name:`String`,description:"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",serialize(e){let t=gn(e);if(typeof t==`string`)return t;if(typeof t==`boolean`)return t?`true`:`false`;if(typeof t==`number`&&Number.isFinite(t))return t.toString();throw new S(`String cannot represent value: ${k(e)}`)},parseValue(e){if(typeof e!=`string`)throw new S(`String cannot represent a non string value: ${k(e)}`);return e},parseLiteral(e){if(e.kind!==E.STRING)throw new S(`String cannot represent a non string value: ${ft(e)}`,{nodes:e});return e.value}}),fn=new Vt({name:`Boolean`,description:"The `Boolean` scalar type represents `true` or `false`.",serialize(e){let t=gn(e);if(typeof t==`boolean`)return t;if(Number.isFinite(t))return t!==0;throw new S(`Boolean cannot represent a non boolean value: ${k(t)}`)},parseValue(e){if(typeof e!=`boolean`)throw new S(`Boolean cannot represent a non boolean value: ${k(e)}`);return e},parseLiteral(e){if(e.kind!==E.BOOLEAN)throw new S(`Boolean cannot represent a non boolean value: ${ft(e)}`,{nodes:e});return e.value}}),pn=new Vt({name:`ID`,description:'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.',serialize(e){let t=gn(e);if(typeof t==`string`)return t;if(Number.isInteger(t))return String(t);throw new S(`ID cannot represent value: ${k(e)}`)},parseValue(e){if(typeof e==`string`)return e;if(typeof e==`number`&&Number.isInteger(e))return e.toString();throw new S(`ID cannot represent value: ${k(e)}`)},parseLiteral(e){if(e.kind!==E.STRING&&e.kind!==E.INT)throw new S(`ID cannot represent a non-string and non-integer value: `+ft(e),{nodes:e});return e.value}}),mn=Object.freeze([dn,ln,un,fn,pn]);function hn(e){return mn.some(({name:t})=>e.name===t)}function gn(e){if(m(e)){if(typeof e.valueOf==`function`){let t=e.valueOf();if(!m(t))return t}if(typeof e.toJSON==`function`)return e.toJSON()}return e}function _n(e){return ze(e,vn)}var vn=class{constructor(e){this.name=yt(e.name),this.description=e.description,this.locations=e.locations,this.isRepeatable=e.isRepeatable??!1,this.extensions=rt(e.extensions),this.astNode=e.astNode,Array.isArray(e.locations)||p(!1,`@${e.name} locations must be an Array.`);let t=e.args??{};m(t)&&!Array.isArray(t)||p(!1,`@${e.name} args must be an object with argument names as keys.`),this.args=Gt(t)}get[Symbol.toStringTag](){return`GraphQLDirective`}toConfig(){return{name:this.name,description:this.description,locations:this.locations,args:Jt(this.args),isRepeatable:this.isRepeatable,extensions:this.extensions,astNode:this.astNode}}toString(){return`@`+this.name}toJSON(){return this.toString()}};const yn=new vn({name:`include`,description:"Directs the executor to include this field or fragment only when the `if` argument is true.",locations:[T.FIELD,T.FRAGMENT_SPREAD,T.INLINE_FRAGMENT],args:{if:{type:new N(fn),description:`Included when true.`}}}),bn=new vn({name:`skip`,description:"Directs the executor to skip this field or fragment when the `if` argument is true.",locations:[T.FIELD,T.FRAGMENT_SPREAD,T.INLINE_FRAGMENT],args:{if:{type:new N(fn),description:`Skipped when true.`}}}),xn=new vn({name:`deprecated`,description:`Marks an element of a GraphQL schema as no longer supported.`,locations:[T.FIELD_DEFINITION,T.ARGUMENT_DEFINITION,T.INPUT_FIELD_DEFINITION,T.ENUM_VALUE],args:{reason:{type:dn,description:`Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).`,defaultValue:`No longer supported`}}}),Sn=new vn({name:`specifiedBy`,description:`Exposes a URL that specifies the behavior of this scalar.`,locations:[T.SCALAR],args:{url:{type:new N(dn),description:`The URL that specifies the behavior of this scalar.`}}}),Cn=new vn({name:`oneOf`,description:"Indicates exactly one field must be supplied and this field must not be `null`.",locations:[T.INPUT_OBJECT],args:{}}),wn=Object.freeze([yn,bn,xn,Sn,Cn]);function Tn(e){return wn.some(({name:t})=>t===e.name)}function En(e){return typeof e==`object`&&typeof e?.[Symbol.iterator]==`function`}function Dn(e,t){if(M(t)){let n=Dn(e,t.ofType);return n?.kind===E.NULL?null:n}if(e===null)return{kind:E.NULL};if(e===void 0)return null;if(Dt(t)){let n=t.ofType;if(En(e)){let t=[];for(let r of e){let e=Dn(r,n);e!=null&&t.push(e)}return{kind:E.LIST,values:t}}return Dn(e,n)}if(Et(t)){if(!m(e))return null;let n=[];for(let r of Object.values(t.getFields())){let t=Dn(e[r.name],r.type);t&&n.push({kind:E.OBJECT_FIELD,name:{kind:E.NAME,value:r.name},value:t})}return{kind:E.OBJECT,fields:n}}if(At(t)){let n=t.serialize(e);if(n==null)return null;if(typeof n==`boolean`)return{kind:E.BOOLEAN,value:n};if(typeof n==`number`&&Number.isFinite(n)){let e=String(n);return On.test(e)?{kind:E.INT,value:e}:{kind:E.FLOAT,value:e}}if(typeof n==`string`)return Tt(t)?{kind:E.ENUM,value:n}:t===pn&&On.test(n)?{kind:E.INT,value:n}:{kind:E.STRING,value:n};throw TypeError(`Cannot convert value to AST: ${k(n)}.`)}h(!1,`Unexpected input type: `+k(t))}const On=/^-?(?:0|[1-9][0-9]*)$/,kn=new Ht({name:`__Schema`,description:`A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.`,fields:()=>({description:{type:dn,resolve:e=>e.description},types:{description:`A list of all types supported by this server.`,type:new N(new Nt(new N(Mn))),resolve(e){return Object.values(e.getTypeMap())}},queryType:{description:`The type that query operations will be rooted at.`,type:new N(Mn),resolve:e=>e.getQueryType()},mutationType:{description:`If this server supports mutation, the type that mutation operations will be rooted at.`,type:Mn,resolve:e=>e.getMutationType()},subscriptionType:{description:`If this server support subscription, the type that subscription operations will be rooted at.`,type:Mn,resolve:e=>e.getSubscriptionType()},directives:{description:`A list of all directives supported by this server.`,type:new N(new Nt(new N(An))),resolve:e=>e.getDirectives()}})}),An=new Ht({name:`__Directive`,description:`A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
49
+
50
+ In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.`,fields:()=>({name:{type:new N(dn),resolve:e=>e.name},description:{type:dn,resolve:e=>e.description},isRepeatable:{type:new N(fn),resolve:e=>e.isRepeatable},locations:{type:new N(new Nt(new N(jn))),resolve:e=>e.locations},args:{type:new N(new Nt(new N(Pn))),args:{includeDeprecated:{type:fn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){return t?e.args:e.args.filter(e=>e.deprecationReason==null)}}})}),jn=new $t({name:`__DirectiveLocation`,description:`A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.`,values:{QUERY:{value:T.QUERY,description:`Location adjacent to a query operation.`},MUTATION:{value:T.MUTATION,description:`Location adjacent to a mutation operation.`},SUBSCRIPTION:{value:T.SUBSCRIPTION,description:`Location adjacent to a subscription operation.`},FIELD:{value:T.FIELD,description:`Location adjacent to a field.`},FRAGMENT_DEFINITION:{value:T.FRAGMENT_DEFINITION,description:`Location adjacent to a fragment definition.`},FRAGMENT_SPREAD:{value:T.FRAGMENT_SPREAD,description:`Location adjacent to a fragment spread.`},INLINE_FRAGMENT:{value:T.INLINE_FRAGMENT,description:`Location adjacent to an inline fragment.`},VARIABLE_DEFINITION:{value:T.VARIABLE_DEFINITION,description:`Location adjacent to a variable definition.`},SCHEMA:{value:T.SCHEMA,description:`Location adjacent to a schema definition.`},SCALAR:{value:T.SCALAR,description:`Location adjacent to a scalar definition.`},OBJECT:{value:T.OBJECT,description:`Location adjacent to an object type definition.`},FIELD_DEFINITION:{value:T.FIELD_DEFINITION,description:`Location adjacent to a field definition.`},ARGUMENT_DEFINITION:{value:T.ARGUMENT_DEFINITION,description:`Location adjacent to an argument definition.`},INTERFACE:{value:T.INTERFACE,description:`Location adjacent to an interface definition.`},UNION:{value:T.UNION,description:`Location adjacent to a union definition.`},ENUM:{value:T.ENUM,description:`Location adjacent to an enum definition.`},ENUM_VALUE:{value:T.ENUM_VALUE,description:`Location adjacent to an enum value definition.`},INPUT_OBJECT:{value:T.INPUT_OBJECT,description:`Location adjacent to an input object type definition.`},INPUT_FIELD_DEFINITION:{value:T.INPUT_FIELD_DEFINITION,description:`Location adjacent to an input object field definition.`}}}),Mn=new Ht({name:`__Type`,description:"The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",fields:()=>({kind:{type:new N(Ln),resolve(e){if(St(e))return In.SCALAR;if(j(e))return In.OBJECT;if(Ct(e))return In.INTERFACE;if(wt(e))return In.UNION;if(Tt(e))return In.ENUM;if(Et(e))return In.INPUT_OBJECT;if(Dt(e))return In.LIST;if(M(e))return In.NON_NULL;h(!1,`Unexpected type: "${k(e)}".`)}},name:{type:dn,resolve:e=>`name`in e?e.name:void 0},description:{type:dn,resolve:e=>`description`in e?e.description:void 0},specifiedByURL:{type:dn,resolve:e=>`specifiedByURL`in e?e.specifiedByURL:void 0},fields:{type:new Nt(new N(Nn)),args:{includeDeprecated:{type:fn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(j(e)||Ct(e)){let n=Object.values(e.getFields());return t?n:n.filter(e=>e.deprecationReason==null)}}},interfaces:{type:new Nt(new N(Mn)),resolve(e){if(j(e)||Ct(e))return e.getInterfaces()}},possibleTypes:{type:new Nt(new N(Mn)),resolve(e,t,n,{schema:r}){if(Mt(e))return r.getPossibleTypes(e)}},enumValues:{type:new Nt(new N(Fn)),args:{includeDeprecated:{type:fn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Tt(e)){let n=e.getValues();return t?n:n.filter(e=>e.deprecationReason==null)}}},inputFields:{type:new Nt(new N(Pn)),args:{includeDeprecated:{type:fn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){if(Et(e)){let n=Object.values(e.getFields());return t?n:n.filter(e=>e.deprecationReason==null)}}},ofType:{type:Mn,resolve:e=>`ofType`in e?e.ofType:void 0},isOneOf:{type:fn,resolve:e=>{if(Et(e))return e.isOneOf}}})}),Nn=new Ht({name:`__Field`,description:`Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.`,fields:()=>({name:{type:new N(dn),resolve:e=>e.name},description:{type:dn,resolve:e=>e.description},args:{type:new N(new Nt(new N(Pn))),args:{includeDeprecated:{type:fn,defaultValue:!1}},resolve(e,{includeDeprecated:t}){return t?e.args:e.args.filter(e=>e.deprecationReason==null)}},type:{type:new N(Mn),resolve:e=>e.type},isDeprecated:{type:new N(fn),resolve:e=>e.deprecationReason!=null},deprecationReason:{type:dn,resolve:e=>e.deprecationReason}})}),Pn=new Ht({name:`__InputValue`,description:`Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.`,fields:()=>({name:{type:new N(dn),resolve:e=>e.name},description:{type:dn,resolve:e=>e.description},type:{type:new N(Mn),resolve:e=>e.type},defaultValue:{type:dn,description:`A GraphQL-formatted string representing the default value for this input value.`,resolve(e){let{type:t,defaultValue:n}=e,r=Dn(n,t);return r?ft(r):null}},isDeprecated:{type:new N(fn),resolve:e=>e.deprecationReason!=null},deprecationReason:{type:dn,resolve:e=>e.deprecationReason}})}),Fn=new Ht({name:`__EnumValue`,description:`One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.`,fields:()=>({name:{type:new N(dn),resolve:e=>e.name},description:{type:dn,resolve:e=>e.description},isDeprecated:{type:new N(fn),resolve:e=>e.deprecationReason!=null},deprecationReason:{type:dn,resolve:e=>e.deprecationReason}})});var In;(function(e){e.SCALAR=`SCALAR`,e.OBJECT=`OBJECT`,e.INTERFACE=`INTERFACE`,e.UNION=`UNION`,e.ENUM=`ENUM`,e.INPUT_OBJECT=`INPUT_OBJECT`,e.LIST=`LIST`,e.NON_NULL=`NON_NULL`})(In||={});const Ln=new $t({name:`__TypeKind`,description:"An enum describing what kind of type a given `__Type` is.",values:{SCALAR:{value:In.SCALAR,description:`Indicates this type is a scalar.`},OBJECT:{value:In.OBJECT,description:"Indicates this type is an object. `fields` and `interfaces` are valid fields."},INTERFACE:{value:In.INTERFACE,description:"Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields."},UNION:{value:In.UNION,description:"Indicates this type is a union. `possibleTypes` is a valid field."},ENUM:{value:In.ENUM,description:"Indicates this type is an enum. `enumValues` is a valid field."},INPUT_OBJECT:{value:In.INPUT_OBJECT,description:"Indicates this type is an input object. `inputFields` is a valid field."},LIST:{value:In.LIST,description:"Indicates this type is a list. `ofType` is a valid field."},NON_NULL:{value:In.NON_NULL,description:"Indicates this type is a non-null. `ofType` is a valid field."}}}),Rn={name:`__schema`,type:new N(kn),description:`Access the current type schema of this server.`,args:[],resolve:(e,t,n,{schema:r})=>r,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},zn={name:`__type`,type:Mn,description:`Request the type information of a single type.`,args:[{name:`name`,description:void 0,type:new N(dn),defaultValue:void 0,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0}],resolve:(e,{name:t},n,{schema:r})=>r.getType(t),deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Bn={name:`__typename`,type:new N(dn),description:`The name of the current Object type at runtime.`,args:[],resolve:(e,t,n,{parentType:r})=>r.name,deprecationReason:void 0,extensions:Object.create(null),astNode:void 0},Vn=Object.freeze([kn,An,jn,Mn,Nn,Pn,Fn,Ln]);function Hn(e){return Vn.some(({name:t})=>e.name===t)}function Un(e){return ze(e,Gn)}function Wn(e){if(!Un(e))throw Error(`Expected ${k(e)} to be a GraphQL schema.`);return e}var Gn=class{constructor(e){this.__validationErrors=e.assumeValid===!0?[]:void 0,m(e)||p(!1,`Must provide configuration object.`),!e.types||Array.isArray(e.types)||p(!1,`"types" must be Array if provided but got: ${k(e.types)}.`),!e.directives||Array.isArray(e.directives)||p(!1,`"directives" must be Array if provided but got: ${k(e.directives)}.`),this.description=e.description,this.extensions=rt(e.extensions),this.astNode=e.astNode,this.extensionASTNodes=e.extensionASTNodes??[],this._queryType=e.query,this._mutationType=e.mutation,this._subscriptionType=e.subscription,this._directives=e.directives??wn;let t=new Set(e.types);if(e.types!=null)for(let n of e.types)t.delete(n),Kn(n,t);this._queryType!=null&&Kn(this._queryType,t),this._mutationType!=null&&Kn(this._mutationType,t),this._subscriptionType!=null&&Kn(this._subscriptionType,t);for(let e of this._directives)if(_n(e))for(let n of e.args)Kn(n.type,t);Kn(kn,t),this._typeMap=Object.create(null),this._subTypeMap=Object.create(null),this._implementationsMap=Object.create(null);for(let e of t){if(e==null)continue;let t=e.name;if(t||p(!1,`One of the provided types for building the Schema is missing a name.`),this._typeMap[t]!==void 0)throw Error(`Schema must contain uniquely named types but contains multiple types named "${t}".`);if(this._typeMap[t]=e,Ct(e)){for(let t of e.getInterfaces())if(Ct(t)){let n=this._implementationsMap[t.name];n===void 0&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.interfaces.push(e)}}else if(j(e)){for(let t of e.getInterfaces())if(Ct(t)){let n=this._implementationsMap[t.name];n===void 0&&(n=this._implementationsMap[t.name]={objects:[],interfaces:[]}),n.objects.push(e)}}}}get[Symbol.toStringTag](){return`GraphQLSchema`}getQueryType(){return this._queryType}getMutationType(){return this._mutationType}getSubscriptionType(){return this._subscriptionType}getRootType(e){switch(e){case ae.QUERY:return this.getQueryType();case ae.MUTATION:return this.getMutationType();case ae.SUBSCRIPTION:return this.getSubscriptionType()}}getTypeMap(){return this._typeMap}getType(e){return this.getTypeMap()[e]}getPossibleTypes(e){return wt(e)?e.getTypes():this.getImplementations(e).objects}getImplementations(e){return this._implementationsMap[e.name]??{objects:[],interfaces:[]}}isSubType(e,t){let n=this._subTypeMap[e.name];if(n===void 0){if(n=Object.create(null),wt(e))for(let t of e.getTypes())n[t.name]=!0;else{let t=this.getImplementations(e);for(let e of t.objects)n[e.name]=!0;for(let e of t.interfaces)n[e.name]=!0}this._subTypeMap[e.name]=n}return n[t.name]!==void 0}getDirectives(){return this._directives}getDirective(e){return this.getDirectives().find(t=>t.name===e)}toConfig(){return{description:this.description,query:this.getQueryType(),mutation:this.getMutationType(),subscription:this.getSubscriptionType(),types:Object.values(this.getTypeMap()),directives:this.getDirectives(),extensions:this.extensions,astNode:this.astNode,extensionASTNodes:this.extensionASTNodes,assumeValid:this.__validationErrors!==void 0}}};function Kn(e,t){let n=Rt(e);if(!t.has(n)){if(t.add(n),wt(n))for(let e of n.getTypes())Kn(e,t);else if(j(n)||Ct(n)){for(let e of n.getInterfaces())Kn(e,t);for(let e of Object.values(n.getFields())){Kn(e.type,t);for(let n of e.args)Kn(n.type,t)}}else if(Et(n))for(let e of Object.values(n.getFields()))Kn(e.type,t)}return t}function qn(e){if(Wn(e),e.__validationErrors)return e.__validationErrors;let t=new Yn(e);Xn(t),Qn(t),er(t);let n=t.getErrors();return e.__validationErrors=n,n}function Jn(e){let t=qn(e);if(t.length!==0)throw Error(t.map(e=>e.message).join(`
51
+
52
+ `))}var Yn=class{constructor(e){this._errors=[],this.schema=e}reportError(e,t){let n=Array.isArray(t)?t.filter(Boolean):t;this._errors.push(new S(e,{nodes:n}))}getErrors(){return this._errors}};function Xn(e){let t=e.schema,n=t.getQueryType();n?j(n)||e.reportError(`Query root type must be Object type, it cannot be ${k(n)}.`,Zn(t,ae.QUERY)??n.astNode):e.reportError(`Query root type must be provided.`,t.astNode);let r=t.getMutationType();r&&!j(r)&&e.reportError(`Mutation root type must be Object type if provided, it cannot be ${k(r)}.`,Zn(t,ae.MUTATION)??r.astNode);let i=t.getSubscriptionType();i&&!j(i)&&e.reportError(`Subscription root type must be Object type if provided, it cannot be ${k(i)}.`,Zn(t,ae.SUBSCRIPTION)??i.astNode)}function Zn(e,t){return[e.astNode,...e.extensionASTNodes].flatMap(e=>e?.operationTypes??[]).find(e=>e.operation===t)?.type}function Qn(e){for(let t of e.schema.getDirectives()){if(!_n(t)){e.reportError(`Expected directive but got: ${k(t)}.`,t?.astNode);continue}$n(e,t),t.locations.length===0&&e.reportError(`Directive @${t.name} must include 1 or more locations.`,t.astNode);for(let n of t.args)$n(e,n),Ot(n.type)||e.reportError(`The type of @${t.name}(${n.name}:) must be Input Type but got: ${k(n.type)}.`,n.astNode),Yt(n)&&n.deprecationReason!=null&&e.reportError(`Required argument @${t.name}(${n.name}:) cannot be deprecated.`,[fr(n.astNode),n.astNode?.type])}}function $n(e,t){t.name.startsWith(`__`)&&e.reportError(`Name "${t.name}" must not begin with "__", which is reserved by GraphQL introspection.`,t.astNode)}function er(e){let t=lr(e),n=e.schema.getTypeMap();for(let r of Object.values(n)){if(!Lt(r)){e.reportError(`Expected GraphQL named type but got: ${k(r)}.`,r.astNode);continue}Hn(r)||$n(e,r),j(r)||Ct(r)?(tr(e,r),nr(e,r)):wt(r)?ar(e,r):Tt(r)?or(e,r):Et(r)&&(sr(e,r),t(r))}}function tr(e,t){let n=Object.values(t.getFields());n.length===0&&e.reportError(`Type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(let r of n){$n(e,r),!kt(r.type)&&e.reportError(`The type of ${t.name}.${r.name} must be Output Type but got: ${k(r.type)}.`,r.astNode?.type);for(let n of r.args){let i=n.name;$n(e,n),!Ot(n.type)&&e.reportError(`The type of ${t.name}.${r.name}(${i}:) must be Input Type but got: ${k(n.type)}.`,n.astNode?.type),Yt(n)&&n.deprecationReason!=null&&e.reportError(`Required argument ${t.name}.${r.name}(${i}:) cannot be deprecated.`,[fr(n.astNode),n.astNode?.type])}}}function nr(e,t){let n=Object.create(null);for(let r of t.getInterfaces()){if(!Ct(r)){e.reportError(`Type ${k(t)} must only implement Interface types, it cannot implement ${k(r)}.`,ur(t,r));continue}if(t===r){e.reportError(`Type ${t.name} cannot implement itself because it would create a circular reference.`,ur(t,r));continue}if(n[r.name]){e.reportError(`Type ${t.name} can only implement ${r.name} once.`,ur(t,r));continue}n[r.name]=!0,ir(e,t,r),rr(e,t,r)}}function rr(e,t,n){let r=t.getFields();for(let i of Object.values(n.getFields())){let a=i.name,o=r[a];if(!o){e.reportError(`Interface field ${n.name}.${a} expected but ${t.name} does not provide it.`,[i.astNode,t.astNode,...t.extensionASTNodes]);continue}sn(e.schema,o.type,i.type)||e.reportError(`Interface field ${n.name}.${a} expects type ${k(i.type)} but ${t.name}.${a} is type ${k(o.type)}.`,[i.astNode?.type,o.astNode?.type]);for(let r of i.args){let i=r.name,s=o.args.find(e=>e.name===i);if(!s){e.reportError(`Interface field argument ${n.name}.${a}(${i}:) expected but ${t.name}.${a} does not provide it.`,[r.astNode,o.astNode]);continue}on(r.type,s.type)||e.reportError(`Interface field argument ${n.name}.${a}(${i}:) expects type ${k(r.type)} but ${t.name}.${a}(${i}:) is type ${k(s.type)}.`,[r.astNode?.type,s.astNode?.type])}for(let r of o.args){let o=r.name;!i.args.find(e=>e.name===o)&&Yt(r)&&e.reportError(`Object field ${t.name}.${a} includes required argument ${o} that is missing from the Interface field ${n.name}.${a}.`,[r.astNode,i.astNode])}}}function ir(e,t,n){let r=t.getInterfaces();for(let i of n.getInterfaces())r.includes(i)||e.reportError(i===t?`Type ${t.name} cannot implement ${n.name} because it would create a circular reference.`:`Type ${t.name} must implement ${i.name} because it is implemented by ${n.name}.`,[...ur(n,i),...ur(t,n)])}function ar(e,t){let n=t.getTypes();n.length===0&&e.reportError(`Union type ${t.name} must define one or more member types.`,[t.astNode,...t.extensionASTNodes]);let r=Object.create(null);for(let i of n){if(r[i.name]){e.reportError(`Union type ${t.name} can only include type ${i.name} once.`,dr(t,i.name));continue}r[i.name]=!0,j(i)||e.reportError(`Union type ${t.name} can only include Object types, it cannot include ${k(i)}.`,dr(t,String(i)))}}function or(e,t){let n=t.getValues();n.length===0&&e.reportError(`Enum type ${t.name} must define one or more values.`,[t.astNode,...t.extensionASTNodes]);for(let t of n)$n(e,t)}function sr(e,t){let n=Object.values(t.getFields());n.length===0&&e.reportError(`Input Object type ${t.name} must define one or more fields.`,[t.astNode,...t.extensionASTNodes]);for(let r of n)$n(e,r),!Ot(r.type)&&e.reportError(`The type of ${t.name}.${r.name} must be Input Type but got: ${k(r.type)}.`,r.astNode?.type),an(r)&&r.deprecationReason!=null&&e.reportError(`Required input field ${t.name}.${r.name} cannot be deprecated.`,[fr(r.astNode),r.astNode?.type]),t.isOneOf&&cr(t,r,e)}function cr(e,t,n){M(t.type)&&n.reportError(`OneOf input field ${e.name}.${t.name} must be nullable.`,t.astNode?.type),t.defaultValue!==void 0&&n.reportError(`OneOf input field ${e.name}.${t.name} cannot have a default value.`,t.astNode)}function lr(e){let t=Object.create(null),n=[],r=Object.create(null);return i;function i(a){if(t[a.name])return;t[a.name]=!0,r[a.name]=n.length;let o=Object.values(a.getFields());for(let t of o)if(M(t.type)&&Et(t.type.ofType)){let a=t.type.ofType,o=r[a.name];if(n.push(t),o===void 0)i(a);else{let t=n.slice(o),r=t.map(e=>e.name).join(`.`);e.reportError(`Cannot reference Input Object "${a.name}" within itself through a series of non-null fields: "${r}".`,t.map(e=>e.astNode))}n.pop()}r[a.name]=void 0}}function ur(e,t){let{astNode:n,extensionASTNodes:r}=e;return(n==null?r:[n,...r]).flatMap(e=>e.interfaces??[]).filter(e=>e.name.value===t.name)}function dr(e,t){let{astNode:n,extensionASTNodes:r}=e;return(n==null?r:[n,...r]).flatMap(e=>e.types??[]).filter(e=>e.name.value===t)}function fr(e){return e?.directives?.find(e=>e.name.value===xn.name)}function pr(e,t){switch(t.kind){case E.LIST_TYPE:{let n=pr(e,t.type);return n&&new Nt(n)}case E.NON_NULL_TYPE:{let n=pr(e,t.type);return n&&new N(n)}case E.NAMED_TYPE:return e.getType(t.name.value)}}var mr=class{constructor(e,t,n){this._schema=e,this._typeStack=[],this._parentTypeStack=[],this._inputTypeStack=[],this._fieldDefStack=[],this._defaultValueStack=[],this._directive=null,this._argument=null,this._enumValue=null,this._getFieldDef=n??hr,t&&(Ot(t)&&this._inputTypeStack.push(t),jt(t)&&this._parentTypeStack.push(t),kt(t)&&this._typeStack.push(t))}get[Symbol.toStringTag](){return`TypeInfo`}getType(){if(this._typeStack.length>0)return this._typeStack[this._typeStack.length-1]}getParentType(){if(this._parentTypeStack.length>0)return this._parentTypeStack[this._parentTypeStack.length-1]}getInputType(){if(this._inputTypeStack.length>0)return this._inputTypeStack[this._inputTypeStack.length-1]}getParentInputType(){if(this._inputTypeStack.length>1)return this._inputTypeStack[this._inputTypeStack.length-2]}getFieldDef(){if(this._fieldDefStack.length>0)return this._fieldDefStack[this._fieldDefStack.length-1]}getDefaultValue(){if(this._defaultValueStack.length>0)return this._defaultValueStack[this._defaultValueStack.length-1]}getDirective(){return this._directive}getArgument(){return this._argument}getEnumValue(){return this._enumValue}enter(e){let t=this._schema;switch(e.kind){case E.SELECTION_SET:{let e=Rt(this.getType());this._parentTypeStack.push(jt(e)?e:void 0);break}case E.FIELD:{let n=this.getParentType(),r,i;n&&(r=this._getFieldDef(t,n,e),r&&(i=r.type)),this._fieldDefStack.push(r),this._typeStack.push(kt(i)?i:void 0);break}case E.DIRECTIVE:this._directive=t.getDirective(e.name.value);break;case E.OPERATION_DEFINITION:{let n=t.getRootType(e.operation);this._typeStack.push(j(n)?n:void 0);break}case E.INLINE_FRAGMENT:case E.FRAGMENT_DEFINITION:{let n=e.typeCondition,r=n?pr(t,n):Rt(this.getType());this._typeStack.push(kt(r)?r:void 0);break}case E.VARIABLE_DEFINITION:{let n=pr(t,e.type);this._inputTypeStack.push(Ot(n)?n:void 0);break}case E.ARGUMENT:{let t,n,r=this.getDirective()??this.getFieldDef();r&&(t=r.args.find(t=>t.name===e.name.value),t&&(n=t.type)),this._argument=t,this._defaultValueStack.push(t?t.defaultValue:void 0),this._inputTypeStack.push(Ot(n)?n:void 0);break}case E.LIST:{let e=It(this.getInputType()),t=Dt(e)?e.ofType:e;this._defaultValueStack.push(void 0),this._inputTypeStack.push(Ot(t)?t:void 0);break}case E.OBJECT_FIELD:{let t=Rt(this.getInputType()),n,r;Et(t)&&(r=t.getFields()[e.name.value],r&&(n=r.type)),this._defaultValueStack.push(r?r.defaultValue:void 0),this._inputTypeStack.push(Ot(n)?n:void 0);break}case E.ENUM:{let t=Rt(this.getInputType()),n;Tt(t)&&(n=t.getValue(e.value)),this._enumValue=n;break}default:}}leave(e){switch(e.kind){case E.SELECTION_SET:this._parentTypeStack.pop();break;case E.FIELD:this._fieldDefStack.pop(),this._typeStack.pop();break;case E.DIRECTIVE:this._directive=null;break;case E.OPERATION_DEFINITION:case E.INLINE_FRAGMENT:case E.FRAGMENT_DEFINITION:this._typeStack.pop();break;case E.VARIABLE_DEFINITION:this._inputTypeStack.pop();break;case E.ARGUMENT:this._argument=null,this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case E.LIST:case E.OBJECT_FIELD:this._defaultValueStack.pop(),this._inputTypeStack.pop();break;case E.ENUM:this._enumValue=null;break;default:}}};function hr(e,t,n){let r=n.name.value;if(r===Rn.name&&e.getQueryType()===t)return Rn;if(r===zn.name&&e.getQueryType()===t)return zn;if(r===Bn.name&&jt(t))return Bn;if(j(t)||Ct(t))return t.getFields()[r]}function gr(e,t){return{enter(...n){let r=n[0];e.enter(r);let i=dt(t,r.kind).enter;if(i){let a=i.apply(t,n);return a!==void 0&&(e.leave(r),ie(a)&&e.enter(a)),a}},leave(...n){let r=n[0],i=dt(t,r.kind).leave,a;return i&&(a=i.apply(t,n)),e.leave(r),a}}}function _r(e){return vr(e)||yr(e)||xr(e)}function vr(e){return e.kind===E.OPERATION_DEFINITION||e.kind===E.FRAGMENT_DEFINITION}function yr(e){return e.kind===E.SCHEMA_DEFINITION||br(e)||e.kind===E.DIRECTIVE_DEFINITION}function br(e){return e.kind===E.SCALAR_TYPE_DEFINITION||e.kind===E.OBJECT_TYPE_DEFINITION||e.kind===E.INTERFACE_TYPE_DEFINITION||e.kind===E.UNION_TYPE_DEFINITION||e.kind===E.ENUM_TYPE_DEFINITION||e.kind===E.INPUT_OBJECT_TYPE_DEFINITION}function xr(e){return e.kind===E.SCHEMA_EXTENSION||Sr(e)}function Sr(e){return e.kind===E.SCALAR_TYPE_EXTENSION||e.kind===E.OBJECT_TYPE_EXTENSION||e.kind===E.INTERFACE_TYPE_EXTENSION||e.kind===E.UNION_TYPE_EXTENSION||e.kind===E.ENUM_TYPE_EXTENSION||e.kind===E.INPUT_OBJECT_TYPE_EXTENSION}function Cr(e){return{Document(t){for(let n of t.definitions)if(!vr(n)){let t=n.kind===E.SCHEMA_DEFINITION||n.kind===E.SCHEMA_EXTENSION?`schema`:`"`+n.name.value+`"`;e.reportError(new S(`The ${t} definition is not executable.`,{nodes:n}))}return!1}}}function wr(e){return{Field(t){let n=e.getParentType();if(n&&!e.getFieldDef()){let r=e.getSchema(),i=t.name.value,a=Ke(`to use an inline fragment on`,Tr(r,n,i));a===``&&(a=Ke(Er(n,i))),e.reportError(new S(`Cannot query field "${i}" on type "${n.name}".`+a,{nodes:t}))}}}}function Tr(e,t,n){if(!Mt(t))return[];let r=new Set,i=Object.create(null);for(let a of e.getPossibleTypes(t))if(a.getFields()[n]){r.add(a),i[a.name]=1;for(let e of a.getInterfaces())e.getFields()[n]&&(r.add(e),i[e.name]=(i[e.name]??0)+1)}return[...r].sort((t,n)=>{let r=i[n.name]-i[t.name];return r===0?Ct(t)&&e.isSubType(t,n)?-1:Ct(n)&&e.isSubType(n,t)?1:Ze(t.name,n.name):r}).map(e=>e.name)}function Er(e,t){return j(e)||Ct(e)?et(t,Object.keys(e.getFields())):[]}function Dr(e){return{InlineFragment(t){let n=t.typeCondition;if(n){let t=pr(e.getSchema(),n);if(t&&!jt(t)){let t=ft(n);e.reportError(new S(`Fragment cannot condition on non composite type "${t}".`,{nodes:n}))}}},FragmentDefinition(t){let n=pr(e.getSchema(),t.typeCondition);if(n&&!jt(n)){let n=ft(t.typeCondition);e.reportError(new S(`Fragment "${t.name.value}" cannot condition on non composite type "${n}".`,{nodes:t.typeCondition}))}}}}function Or(e){return{...kr(e),Argument(t){let n=e.getArgument(),r=e.getFieldDef(),i=e.getParentType();if(!n&&r&&i){let n=t.name.value,a=et(n,r.args.map(e=>e.name));e.reportError(new S(`Unknown argument "${n}" on field "${i.name}.${r.name}".`+Ke(a),{nodes:t}))}}}}function kr(e){let t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():wn;for(let e of r)t[e.name]=e.args.map(e=>e.name);let i=e.getDocument().definitions;for(let e of i)if(e.kind===E.DIRECTIVE_DEFINITION){let n=e.arguments??[];t[e.name.value]=n.map(e=>e.name.value)}return{Directive(n){let r=n.name.value,i=t[r];if(n.arguments&&i)for(let t of n.arguments){let n=t.name.value;if(!i.includes(n)){let a=et(n,i);e.reportError(new S(`Unknown argument "${n}" on directive "@${r}".`+Ke(a),{nodes:t}))}}return!1}}}function Ar(e){let t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():wn;for(let e of r)t[e.name]=e.locations;let i=e.getDocument().definitions;for(let e of i)e.kind===E.DIRECTIVE_DEFINITION&&(t[e.name.value]=e.locations.map(e=>e.value));return{Directive(n,r,i,a,o){let s=n.name.value,c=t[s];if(!c){e.reportError(new S(`Unknown directive "@${s}".`,{nodes:n}));return}let l=jr(o);l&&!c.includes(l)&&e.reportError(new S(`Directive "@${s}" may not be used on ${l}.`,{nodes:n}))}}}function jr(e){let t=e[e.length-1];switch(`kind`in t||h(!1),t.kind){case E.OPERATION_DEFINITION:return Mr(t.operation);case E.FIELD:return T.FIELD;case E.FRAGMENT_SPREAD:return T.FRAGMENT_SPREAD;case E.INLINE_FRAGMENT:return T.INLINE_FRAGMENT;case E.FRAGMENT_DEFINITION:return T.FRAGMENT_DEFINITION;case E.VARIABLE_DEFINITION:return T.VARIABLE_DEFINITION;case E.SCHEMA_DEFINITION:case E.SCHEMA_EXTENSION:return T.SCHEMA;case E.SCALAR_TYPE_DEFINITION:case E.SCALAR_TYPE_EXTENSION:return T.SCALAR;case E.OBJECT_TYPE_DEFINITION:case E.OBJECT_TYPE_EXTENSION:return T.OBJECT;case E.FIELD_DEFINITION:return T.FIELD_DEFINITION;case E.INTERFACE_TYPE_DEFINITION:case E.INTERFACE_TYPE_EXTENSION:return T.INTERFACE;case E.UNION_TYPE_DEFINITION:case E.UNION_TYPE_EXTENSION:return T.UNION;case E.ENUM_TYPE_DEFINITION:case E.ENUM_TYPE_EXTENSION:return T.ENUM;case E.ENUM_VALUE_DEFINITION:return T.ENUM_VALUE;case E.INPUT_OBJECT_TYPE_DEFINITION:case E.INPUT_OBJECT_TYPE_EXTENSION:return T.INPUT_OBJECT;case E.INPUT_VALUE_DEFINITION:{let t=e[e.length-3];return`kind`in t||h(!1),t.kind===E.INPUT_OBJECT_TYPE_DEFINITION?T.INPUT_FIELD_DEFINITION:T.ARGUMENT_DEFINITION}default:h(!1,`Unexpected kind: `+k(t.kind))}}function Mr(e){switch(e){case ae.QUERY:return T.QUERY;case ae.MUTATION:return T.MUTATION;case ae.SUBSCRIPTION:return T.SUBSCRIPTION}}function Nr(e){return{FragmentSpread(t){let n=t.name.value;e.getFragment(n)||e.reportError(new S(`Unknown fragment "${n}".`,{nodes:t.name}))}}}function Pr(e){let t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);for(let t of e.getDocument().definitions)br(t)&&(r[t.name.value]=!0);let i=[...Object.keys(n),...Object.keys(r)];return{NamedType(t,a,o,s,c){let l=t.name.value;if(!n[l]&&!r[l]){let n=c[2]??o,r=n!=null&&Ir(n);if(r&&Fr.includes(l))return;let a=et(l,r?Fr.concat(i):i);e.reportError(new S(`Unknown type "${l}".`+Ke(a),{nodes:t}))}}}}const Fr=[...mn,...Vn].map(e=>e.name);function Ir(e){return`kind`in e&&(yr(e)||xr(e))}function Lr(e){let t=0;return{Document(e){t=e.definitions.filter(e=>e.kind===E.OPERATION_DEFINITION).length},OperationDefinition(n){!n.name&&t>1&&e.reportError(new S(`This anonymous operation must be the only defined operation.`,{nodes:n}))}}}function Rr(e){let t=e.getSchema(),n=t?.astNode??t?.getQueryType()??t?.getMutationType()??t?.getSubscriptionType(),r=0;return{SchemaDefinition(t){if(n){e.reportError(new S(`Cannot define a new schema within a schema extension.`,{nodes:t}));return}r>0&&e.reportError(new S(`Must provide only one schema definition.`,{nodes:t})),++r}}}function zr(e){function t(n,r=Object.create(null),i=0){if(n.kind===E.FRAGMENT_SPREAD){let a=n.name.value;if(r[a]===!0)return!1;let o=e.getFragment(a);if(!o)return!1;try{return r[a]=!0,t(o,r,i)}finally{r[a]=void 0}}if(n.kind===E.FIELD&&(n.name.value===`fields`||n.name.value===`interfaces`||n.name.value===`possibleTypes`||n.name.value===`inputFields`)&&(i++,i>=3))return!0;if(`selectionSet`in n&&n.selectionSet){for(let e of n.selectionSet.selections)if(t(e,r,i))return!0}return!1}return{Field(n){if((n.name.value===`__schema`||n.name.value===`__type`)&&t(n))return e.reportError(new S(`Maximum introspection depth exceeded`,{nodes:[n]})),!1}}}function Br(e){let t=Object.create(null),n=[],r=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(e){return i(e),!1}};function i(a){if(t[a.name.value])return;let o=a.name.value;t[o]=!0;let s=e.getFragmentSpreads(a.selectionSet);if(s.length!==0){r[o]=n.length;for(let t of s){let a=t.name.value,o=r[a];if(n.push(t),o===void 0){let t=e.getFragment(a);t&&i(t)}else{let t=n.slice(o),r=t.slice(0,-1).map(e=>`"`+e.name.value+`"`).join(`, `);e.reportError(new S(`Cannot spread fragment "${a}" within itself`+(r===``?`.`:` via ${r}.`),{nodes:t}))}n.pop()}r[o]=void 0}}}function Vr(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){let r=e.getRecursiveVariableUsages(n);for(let{node:i}of r){let r=i.name.value;t[r]!==!0&&e.reportError(new S(n.name?`Variable "$${r}" is not defined by operation "${n.name.value}".`:`Variable "$${r}" is not defined.`,{nodes:[i,n]}))}}},VariableDefinition(e){t[e.variable.name.value]=!0}}}function Hr(e){let t=[],n=[];return{OperationDefinition(e){return t.push(e),!1},FragmentDefinition(e){return n.push(e),!1},Document:{leave(){let r=Object.create(null);for(let n of t)for(let t of e.getRecursivelyReferencedFragments(n))r[t.name.value]=!0;for(let t of n){let n=t.name.value;r[n]!==!0&&e.reportError(new S(`Fragment "${n}" is never used.`,{nodes:t}))}}}}}function Ur(e){let t=[];return{OperationDefinition:{enter(){t=[]},leave(n){let r=Object.create(null),i=e.getRecursiveVariableUsages(n);for(let{node:e}of i)r[e.name.value]=!0;for(let i of t){let t=i.variable.name.value;r[t]!==!0&&e.reportError(new S(n.name?`Variable "$${t}" is never used in operation "${n.name.value}".`:`Variable "$${t}" is never used.`,{nodes:i}))}}},VariableDefinition(e){t.push(e)}}}function Wr(e){switch(e.kind){case E.OBJECT:return{...e,fields:Gr(e.fields)};case E.LIST:return{...e,values:e.values.map(Wr)};case E.INT:case E.FLOAT:case E.STRING:case E.BOOLEAN:case E.NULL:case E.ENUM:case E.VARIABLE:return e}}function Gr(e){return e.map(e=>({...e,value:Wr(e.value)})).sort((e,t)=>Ze(e.name.value,t.name.value))}function Kr(e){return Array.isArray(e)?e.map(([e,t])=>`subfields "${e}" conflict because `+Kr(t)).join(` and `):e}function qr(e){let t=new ci,n=new li,r=new Map;return{SelectionSet(i){let a=Jr(e,r,t,n,e.getParentType(),i);for(let[[t,n],r,i]of a){let a=Kr(n);e.reportError(new S(`Fields "${t}" conflict because ${a}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:r.concat(i)}))}}}}function Jr(e,t,n,r,i,a){let o=[],[s,c]=ii(e,t,i,a);if(Qr(e,o,t,n,r,s),c.length!==0)for(let i=0;i<c.length;i++){Yr(e,o,t,n,r,!1,s,c[i]);for(let a=i+1;a<c.length;a++)Xr(e,o,t,n,r,!1,c[i],c[a])}return o}function Yr(e,t,n,r,i,a,o,s){if(r.has(o,s,a))return;r.add(o,s,a);let c=e.getFragment(s);if(!c)return;let[l,u]=ai(e,n,c);if(o!==l){$r(e,t,n,r,i,a,o,l);for(let s of u)Yr(e,t,n,r,i,a,o,s)}}function Xr(e,t,n,r,i,a,o,s){if(o===s||i.has(o,s,a))return;i.add(o,s,a);let c=e.getFragment(o),l=e.getFragment(s);if(!c||!l)return;let[u,d]=ai(e,n,c),[f,p]=ai(e,n,l);$r(e,t,n,r,i,a,u,f);for(let s of p)Xr(e,t,n,r,i,a,o,s);for(let o of d)Xr(e,t,n,r,i,a,o,s)}function Zr(e,t,n,r,i,a,o,s,c){let l=[],[u,d]=ii(e,t,a,o),[f,p]=ii(e,t,s,c);$r(e,l,t,n,r,i,u,f);for(let a of p)Yr(e,l,t,n,r,i,u,a);for(let a of d)Yr(e,l,t,n,r,i,f,a);for(let a of d)for(let o of p)Xr(e,l,t,n,r,i,a,o);return l}function Qr(e,t,n,r,i,a){for(let[o,s]of Object.entries(a))if(s.length>1)for(let a=0;a<s.length;a++)for(let c=a+1;c<s.length;c++){let l=ei(e,n,r,i,!1,o,s[a],s[c]);l&&t.push(l)}}function $r(e,t,n,r,i,a,o,s){for(let[c,l]of Object.entries(o)){let o=s[c];if(o)for(let s of l)for(let l of o){let o=ei(e,n,r,i,a,c,s,l);o&&t.push(o)}}}function ei(e,t,n,r,i,a,o,s){let[c,l,u]=o,[d,f,p]=s,m=i||c!==d&&j(c)&&j(d);if(!m){let e=l.name.value,t=f.name.value;if(e!==t)return[[a,`"${e}" and "${t}" are different fields`],[l],[f]];if(!ti(l,f))return[[a,`they have differing arguments`],[l],[f]]}let h=u?.type,g=p?.type;if(h&&g&&ri(h,g))return[[a,`they return conflicting types "${k(h)}" and "${k(g)}"`],[l],[f]];let _=l.selectionSet,v=f.selectionSet;if(_&&v)return si(Zr(e,t,n,r,m,Rt(h),_,Rt(g),v),a,l,f)}function ti(e,t){let n=e.arguments,r=t.arguments;if(n===void 0||n.length===0)return r===void 0||r.length===0;if(r===void 0||r.length===0||n.length!==r.length)return!1;let i=new Map(r.map(({name:e,value:t})=>[e.value,t]));return n.every(e=>{let t=e.value,n=i.get(e.name.value);return n===void 0?!1:ni(t)===ni(n)})}function ni(e){return ft(Wr(e))}function ri(e,t){return Dt(e)?Dt(t)?ri(e.ofType,t.ofType):!0:Dt(t)?!0:M(e)?M(t)?ri(e.ofType,t.ofType):!0:M(t)?!0:At(e)||At(t)?e!==t:!1}function ii(e,t,n,r){let i=t.get(r);if(i)return i;let a=Object.create(null),o=Object.create(null);oi(e,n,r,a,o);let s=[a,Object.keys(o)];return t.set(r,s),s}function ai(e,t,n){return t.get(n.selectionSet)||ii(e,t,pr(e.getSchema(),n.typeCondition),n.selectionSet)}function oi(e,t,n,r,i){for(let a of n.selections)switch(a.kind){case E.FIELD:{let e=a.name.value,n;(j(t)||Ct(t))&&(n=t.getFields()[e]);let i=a.alias?a.alias.value:e;r[i]||(r[i]=[]),r[i].push([t,a,n]);break}case E.FRAGMENT_SPREAD:i[a.name.value]=!0;break;case E.INLINE_FRAGMENT:{let n=a.typeCondition;oi(e,n?pr(e.getSchema(),n):t,a.selectionSet,r,i);break}}}function si(e,t,n,r){if(e.length>0)return[[t,e.map(([e])=>e)],[n,...e.map(([,e])=>e).flat()],[r,...e.map(([,,e])=>e).flat()]]}var ci=class{constructor(){this._data=new Map}has(e,t,n){let r=this._data.get(e)?.get(t);return r===void 0?!1:n?!0:n===r}add(e,t,n){let r=this._data.get(e);r===void 0?this._data.set(e,new Map([[t,n]])):r.set(t,n)}},li=class{constructor(){this._orderedPairSet=new ci}has(e,t,n){return e<t?this._orderedPairSet.has(e,t,n):this._orderedPairSet.has(t,e,n)}add(e,t,n){e<t?this._orderedPairSet.add(e,t,n):this._orderedPairSet.add(t,e,n)}};function ui(e){return{InlineFragment(t){let n=e.getType(),r=e.getParentType();if(jt(n)&&jt(r)&&!cn(e.getSchema(),n,r)){let i=k(r),a=k(n);e.reportError(new S(`Fragment cannot be spread here as objects of type "${i}" can never be of type "${a}".`,{nodes:t}))}},FragmentSpread(t){let n=t.name.value,r=di(e,n),i=e.getParentType();if(r&&i&&!cn(e.getSchema(),r,i)){let a=k(i),o=k(r);e.reportError(new S(`Fragment "${n}" cannot be spread here as objects of type "${a}" can never be of type "${o}".`,{nodes:t}))}}}}function di(e,t){let n=e.getFragment(t);if(n){let t=pr(e.getSchema(),n.typeCondition);if(jt(t))return t}}function fi(e){let t=e.getSchema(),n=Object.create(null);for(let t of e.getDocument().definitions)br(t)&&(n[t.name.value]=t);return{ScalarTypeExtension:r,ObjectTypeExtension:r,InterfaceTypeExtension:r,UnionTypeExtension:r,EnumTypeExtension:r,InputObjectTypeExtension:r};function r(r){let i=r.name.value,a=n[i],o=t?.getType(i),s;if(a?s=pi[a.kind]:o&&(s=mi(o)),s){if(s!==r.kind){let t=hi(r.kind);e.reportError(new S(`Cannot extend non-${t} type "${i}".`,{nodes:a?[a,r]:r}))}}else{let a=et(i,Object.keys({...n,...t?.getTypeMap()}));e.reportError(new S(`Cannot extend type "${i}" because it is not defined.`+Ke(a),{nodes:r.name}))}}}const pi={[E.SCALAR_TYPE_DEFINITION]:E.SCALAR_TYPE_EXTENSION,[E.OBJECT_TYPE_DEFINITION]:E.OBJECT_TYPE_EXTENSION,[E.INTERFACE_TYPE_DEFINITION]:E.INTERFACE_TYPE_EXTENSION,[E.UNION_TYPE_DEFINITION]:E.UNION_TYPE_EXTENSION,[E.ENUM_TYPE_DEFINITION]:E.ENUM_TYPE_EXTENSION,[E.INPUT_OBJECT_TYPE_DEFINITION]:E.INPUT_OBJECT_TYPE_EXTENSION};function mi(e){if(St(e))return E.SCALAR_TYPE_EXTENSION;if(j(e))return E.OBJECT_TYPE_EXTENSION;if(Ct(e))return E.INTERFACE_TYPE_EXTENSION;if(wt(e))return E.UNION_TYPE_EXTENSION;if(Tt(e))return E.ENUM_TYPE_EXTENSION;if(Et(e))return E.INPUT_OBJECT_TYPE_EXTENSION;h(!1,`Unexpected type: `+k(e))}function hi(e){switch(e){case E.SCALAR_TYPE_EXTENSION:return`scalar`;case E.OBJECT_TYPE_EXTENSION:return`object`;case E.INTERFACE_TYPE_EXTENSION:return`interface`;case E.UNION_TYPE_EXTENSION:return`union`;case E.ENUM_TYPE_EXTENSION:return`enum`;case E.INPUT_OBJECT_TYPE_EXTENSION:return`input object`;default:h(!1,`Unexpected kind: `+k(e))}}function gi(e){return{..._i(e),Field:{leave(t){let n=e.getFieldDef();if(!n)return!1;let r=new Set(t.arguments?.map(e=>e.name.value));for(let i of n.args)if(!r.has(i.name)&&Yt(i)){let r=k(i.type);e.reportError(new S(`Field "${n.name}" argument "${i.name}" of type "${r}" is required, but it was not provided.`,{nodes:t}))}}}}}function _i(e){let t=Object.create(null),n=e.getSchema()?.getDirectives()??wn;for(let e of n)t[e.name]=Je(e.args.filter(Yt),e=>e.name);let r=e.getDocument().definitions;for(let e of r)if(e.kind===E.DIRECTIVE_DEFINITION){let n=e.arguments??[];t[e.name.value]=Je(n.filter(vi),e=>e.name.value)}return{Directive:{leave(n){let r=n.name.value,i=t[r];if(i){let t=n.arguments??[],a=new Set(t.map(e=>e.name.value));for(let[t,o]of Object.entries(i))if(!a.has(t)){let i=xt(o.type)?k(o.type):ft(o.type);e.reportError(new S(`Directive "@${r}" argument "${t}" of type "${i}" is required, but it was not provided.`,{nodes:n}))}}}}}}function vi(e){return e.type.kind===E.NON_NULL_TYPE&&e.defaultValue==null}function yi(e){return{Field(t){let n=e.getType(),r=t.selectionSet;if(n){if(At(Rt(n))){if(r){let i=t.name.value,a=k(n);e.reportError(new S(`Field "${i}" must not have a selection since type "${a}" has no subfields.`,{nodes:r}))}}else if(!r){let r=t.name.value,i=k(n);e.reportError(new S(`Field "${r}" of type "${i}" must have a selection of subfields. Did you mean "${r} { ... }"?`,{nodes:t}))}else if(r.selections.length===0){let r=t.name.value,i=k(n);e.reportError(new S(`Field "${r}" of type "${i}" must have at least one field selected.`,{nodes:t}))}}}}}function bi(e){return e.map(e=>typeof e==`number`?`[`+e.toString()+`]`:`.`+e).join(``)}function xi(e,t,n){return{prev:e,key:t,typename:n}}function Si(e){let t=[],n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function Ci(e,t,n=wi){return Ti(e,t,n,void 0)}function wi(e,t,n){let r=`Invalid value `+k(t);throw e.length>0&&(r+=` at "value${bi(e)}"`),n.message=r+`: `+n.message,n}function Ti(e,t,n,r){if(M(t)){if(e!=null)return Ti(e,t.ofType,n,r);n(Si(r),e,new S(`Expected non-nullable type "${k(t)}" not to be null.`));return}if(e==null)return null;if(Dt(t)){let i=t.ofType;return En(e)?Array.from(e,(e,t)=>{let a=xi(r,t,void 0);return Ti(e,i,n,a)}):[Ti(e,i,n,r)]}if(Et(t)){if(!m(e)||Array.isArray(e)){n(Si(r),e,new S(`Expected type "${t.name}" to be an object.`));return}let i={},a=t.getFields();for(let o of Object.values(a)){let a=e[o.name];if(a===void 0){if(o.defaultValue!==void 0)i[o.name]=o.defaultValue;else if(M(o.type)){let t=k(o.type);n(Si(r),e,new S(`Field "${o.name}" of required type "${t}" was not provided.`))}continue}i[o.name]=Ti(a,o.type,n,xi(r,o.name,t.name))}for(let i of Object.keys(e))if(!a[i]){let a=et(i,Object.keys(t.getFields()));n(Si(r),e,new S(`Field "${i}" is not defined by type "${t.name}".`+Ke(a)))}if(t.isOneOf){let a=Object.keys(i);a.length!==1&&n(Si(r),e,new S(`Exactly one key must be specified for OneOf type "${t.name}".`));let o=a[0],s=i[o];s===null&&n(Si(r).concat(o),s,new S(`Field "${o}" must be non-null.`))}return i}if(At(t)){let i;try{i=t.parseValue(e)}catch(i){i instanceof S?n(Si(r),e,i):n(Si(r),e,new S(`Expected type "${t.name}". `+i.message,{originalError:i}));return}return i===void 0&&n(Si(r),e,new S(`Expected type "${t.name}".`)),i}h(!1,`Unexpected input type: `+k(t))}function Ei(e,t,n){if(e){if(e.kind===E.VARIABLE){let r=e.name.value;if(n==null||n[r]===void 0)return;let i=n[r];return i===null&&M(t)?void 0:i}if(M(t))return e.kind===E.NULL?void 0:Ei(e,t.ofType,n);if(e.kind===E.NULL)return null;if(Dt(t)){let r=t.ofType;if(e.kind===E.LIST){let t=[];for(let i of e.values)if(Di(i,n)){if(M(r))return;t.push(null)}else{let e=Ei(i,r,n);if(e===void 0)return;t.push(e)}return t}let i=Ei(e,r,n);return i===void 0?void 0:[i]}if(Et(t)){if(e.kind!==E.OBJECT)return;let r=Object.create(null),i=Je(e.fields,e=>e.name.value);for(let e of Object.values(t.getFields())){let t=i[e.name];if(!t||Di(t.value,n)){if(e.defaultValue!==void 0)r[e.name]=e.defaultValue;else if(M(e.type))return;continue}let a=Ei(t.value,e.type,n);if(a===void 0)return;r[e.name]=a}if(t.isOneOf){let e=Object.keys(r);if(e.length!==1||r[e[0]]===null)return}return r}if(At(t)){let r;try{r=t.parseLiteral(e,n)}catch{return}return r===void 0?void 0:r}h(!1,`Unexpected input type: `+k(t))}}function Di(e,t){return e.kind===E.VARIABLE&&(t==null||t[e.name.value]===void 0)}function Oi(e,t,n){let r={},i=Je(t.arguments??[],e=>e.name.value);for(let a of e.args){let e=a.name,o=a.type,s=i[e];if(!s){if(a.defaultValue!==void 0)r[e]=a.defaultValue;else if(M(o))throw new S(`Argument "${e}" of required type "${k(o)}" was not provided.`,{nodes:t});continue}let c=s.value,l=c.kind===E.NULL;if(c.kind===E.VARIABLE){let t=c.name.value;if(n==null||!Ai(n,t)){if(a.defaultValue!==void 0)r[e]=a.defaultValue;else if(M(o))throw new S(`Argument "${e}" of required type "${k(o)}" was provided the variable "$${t}" which was not provided a runtime value.`,{nodes:c});continue}l=n[t]==null}if(l&&M(o))throw new S(`Argument "${e}" of non-null type "${k(o)}" must not be null.`,{nodes:c});let u=Ei(c,o,n);if(u===void 0)throw new S(`Argument "${e}" has invalid value ${ft(c)}.`,{nodes:c});r[e]=u}return r}function ki(e,t,n){let r=t.directives?.find(t=>t.name.value===e.name);if(r)return Oi(e,r,n)}function Ai(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ji(e,t,n,r,i){let a=new Map;return Mi(e,t,n,r,i,a,new Set),a}function Mi(e,t,n,r,i,a,o){for(let s of i.selections)switch(s.kind){case E.FIELD:{if(!Ni(n,s))continue;let e=Fi(s),t=a.get(e);t===void 0?a.set(e,[s]):t.push(s);break}case E.INLINE_FRAGMENT:if(!Ni(n,s)||!Pi(e,s,r))continue;Mi(e,t,n,r,s.selectionSet,a,o);break;case E.FRAGMENT_SPREAD:{let i=s.name.value;if(o.has(i)||!Ni(n,s))continue;o.add(i);let c=t[i];if(!c||!Pi(e,c,r))continue;Mi(e,t,n,r,c.selectionSet,a,o);break}}}function Ni(e,t){return ki(bn,t,e)?.if===!0?!1:ki(yn,t,e)?.if!==!1}function Pi(e,t,n){let r=t.typeCondition;if(!r)return!0;let i=pr(e,r);return i===n?!0:Mt(i)?e.isSubType(i,n):!1}function Fi(e){return e.alias?e.alias.value:e.name.value}function Ii(e){return{OperationDefinition(t){if(t.operation===`subscription`){let n=e.getSchema(),r=n.getSubscriptionType();if(r){let i=t.name?t.name.value:null,a=Object.create(null),o=e.getDocument(),s=Object.create(null);for(let e of o.definitions)e.kind===E.FRAGMENT_DEFINITION&&(s[e.name.value]=e);let c=ji(n,s,a,r,t.selectionSet);if(c.size>1){let t=[...c.values()].slice(1).flat();e.reportError(new S(i==null?`Anonymous Subscription must select only one top level field.`:`Subscription "${i}" must select only one top level field.`,{nodes:t}))}for(let t of c.values())t[0].name.value.startsWith(`__`)&&e.reportError(new S(i==null?`Anonymous Subscription must not select an introspection top level field.`:`Subscription "${i}" must not select an introspection top level field.`,{nodes:t}))}}}}}function Li(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i===void 0?n.set(e,[r]):i.push(r)}return n}function Ri(e){return{DirectiveDefinition(e){let t=e.arguments??[];return n(`@${e.name.value}`,t)},InterfaceTypeDefinition:t,InterfaceTypeExtension:t,ObjectTypeDefinition:t,ObjectTypeExtension:t};function t(e){let t=e.name.value,r=e.fields??[];for(let e of r){let r=e.name.value,i=e.arguments??[];n(`${t}.${r}`,i)}return!1}function n(t,n){let r=Li(n,e=>e.name.value);for(let[n,i]of r)i.length>1&&e.reportError(new S(`Argument "${t}(${n}:)" can only be defined once.`,{nodes:i.map(e=>e.name)}));return!1}}function zi(e){return{Field:t,Directive:t};function t(t){let n=Li(t.arguments??[],e=>e.name.value);for(let[t,r]of n)r.length>1&&e.reportError(new S(`There can be only one argument named "${t}".`,{nodes:r.map(e=>e.name)}))}}function Bi(e){let t=Object.create(null),n=e.getSchema();return{DirectiveDefinition(r){let i=r.name.value;if(n!=null&&n.getDirective(i)){e.reportError(new S(`Directive "@${i}" already exists in the schema. It cannot be redefined.`,{nodes:r.name}));return}return t[i]?e.reportError(new S(`There can be only one directive named "@${i}".`,{nodes:[t[i],r.name]})):t[i]=r.name,!1}}}function Vi(e){let t=Object.create(null),n=e.getSchema(),r=n?n.getDirectives():wn;for(let e of r)t[e.name]=!e.isRepeatable;let i=e.getDocument().definitions;for(let e of i)e.kind===E.DIRECTIVE_DEFINITION&&(t[e.name.value]=!e.repeatable);let a=Object.create(null),o=Object.create(null);return{enter(n){if(!(`directives`in n)||!n.directives)return;let r;if(n.kind===E.SCHEMA_DEFINITION||n.kind===E.SCHEMA_EXTENSION)r=a;else if(br(n)||Sr(n)){let e=n.name.value;r=o[e],r===void 0&&(o[e]=r=Object.create(null))}else r=Object.create(null);for(let i of n.directives){let n=i.name.value;t[n]&&(r[n]?e.reportError(new S(`The directive "@${n}" can only be used once at this location.`,{nodes:[r[n],i]})):r[n]=i)}}}}function Hi(e){let t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);return{EnumTypeDefinition:i,EnumTypeExtension:i};function i(t){let i=t.name.value;r[i]||(r[i]=Object.create(null));let a=t.values??[],o=r[i];for(let t of a){let r=t.name.value,a=n[i];Tt(a)&&a.getValue(r)?e.reportError(new S(`Enum value "${i}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,{nodes:t.name})):o[r]?e.reportError(new S(`Enum value "${i}.${r}" can only be defined once.`,{nodes:[o[r],t.name]})):o[r]=t.name}return!1}}function Ui(e){let t=e.getSchema(),n=t?t.getTypeMap():Object.create(null),r=Object.create(null);return{InputObjectTypeDefinition:i,InputObjectTypeExtension:i,InterfaceTypeDefinition:i,InterfaceTypeExtension:i,ObjectTypeDefinition:i,ObjectTypeExtension:i};function i(t){let i=t.name.value;r[i]||(r[i]=Object.create(null));let a=t.fields??[],o=r[i];for(let t of a){let r=t.name.value;Wi(n[i],r)?e.reportError(new S(`Field "${i}.${r}" already exists in the schema. It cannot also be defined in this type extension.`,{nodes:t.name})):o[r]?e.reportError(new S(`Field "${i}.${r}" can only be defined once.`,{nodes:[o[r],t.name]})):o[r]=t.name}return!1}}function Wi(e,t){return j(e)||Ct(e)||Et(e)?e.getFields()[t]!=null:!1}function Gi(e){let t=Object.create(null);return{OperationDefinition:()=>!1,FragmentDefinition(n){let r=n.name.value;return t[r]?e.reportError(new S(`There can be only one fragment named "${r}".`,{nodes:[t[r],n.name]})):t[r]=n.name,!1}}}function Ki(e){let t=[],n=Object.create(null);return{ObjectValue:{enter(){t.push(n),n=Object.create(null)},leave(){let e=t.pop();e||h(!1),n=e}},ObjectField(t){let r=t.name.value;n[r]?e.reportError(new S(`There can be only one input field named "${r}".`,{nodes:[n[r],t.name]})):n[r]=t.name}}}function qi(e){let t=Object.create(null);return{OperationDefinition(n){let r=n.name;return r&&(t[r.value]?e.reportError(new S(`There can be only one operation named "${r.value}".`,{nodes:[t[r.value],r]})):t[r.value]=r),!1},FragmentDefinition:()=>!1}}function Ji(e){let t=e.getSchema(),n=Object.create(null),r=t?{query:t.getQueryType(),mutation:t.getMutationType(),subscription:t.getSubscriptionType()}:{};return{SchemaDefinition:i,SchemaExtension:i};function i(t){let i=t.operationTypes??[];for(let t of i){let i=t.operation,a=n[i];r[i]?e.reportError(new S(`Type for ${i} already defined in the schema. It cannot be redefined.`,{nodes:t})):a?e.reportError(new S(`There can be only one ${i} type in schema.`,{nodes:[a,t]})):n[i]=t}return!1}}function Yi(e){let t=Object.create(null),n=e.getSchema();return{ScalarTypeDefinition:r,ObjectTypeDefinition:r,InterfaceTypeDefinition:r,UnionTypeDefinition:r,EnumTypeDefinition:r,InputObjectTypeDefinition:r};function r(r){let i=r.name.value;if(n!=null&&n.getType(i)){e.reportError(new S(`Type "${i}" already exists in the schema. It cannot also be defined in this type definition.`,{nodes:r.name}));return}return t[i]?e.reportError(new S(`There can be only one type named "${i}".`,{nodes:[t[i],r.name]})):t[i]=r.name,!1}}function Xi(e){return{OperationDefinition(t){let n=Li(t.variableDefinitions??[],e=>e.variable.name.value);for(let[t,r]of n)r.length>1&&e.reportError(new S(`There can be only one variable named "$${t}".`,{nodes:r.map(e=>e.variable.name)}))}}}function Zi(e){let t={};return{OperationDefinition:{enter(){t={}}},VariableDefinition(e){t[e.variable.name.value]=e},ListValue(t){if(!Dt(It(e.getParentInputType())))return Qi(e,t),!1},ObjectValue(n){let r=Rt(e.getInputType());if(!Et(r))return Qi(e,n),!1;let i=Je(n.fields,e=>e.name.value);for(let t of Object.values(r.getFields()))if(!i[t.name]&&an(t)){let i=k(t.type);e.reportError(new S(`Field "${r.name}.${t.name}" of required type "${i}" was not provided.`,{nodes:n}))}r.isOneOf&&$i(e,n,r,i,t)},ObjectField(t){let n=Rt(e.getParentInputType());if(!e.getInputType()&&Et(n)){let r=et(t.name.value,Object.keys(n.getFields()));e.reportError(new S(`Field "${t.name.value}" is not defined by type "${n.name}".`+Ke(r),{nodes:t}))}},NullValue(t){let n=e.getInputType();M(n)&&e.reportError(new S(`Expected value of type "${k(n)}", found ${ft(t)}.`,{nodes:t}))},EnumValue:t=>Qi(e,t),IntValue:t=>Qi(e,t),FloatValue:t=>Qi(e,t),StringValue:t=>Qi(e,t),BooleanValue:t=>Qi(e,t)}}function Qi(e,t){let n=e.getInputType();if(!n)return;let r=Rt(n);if(!At(r)){let r=k(n);e.reportError(new S(`Expected value of type "${r}", found ${ft(t)}.`,{nodes:t}));return}try{if(r.parseLiteral(t,void 0)===void 0){let r=k(n);e.reportError(new S(`Expected value of type "${r}", found ${ft(t)}.`,{nodes:t}))}}catch(r){let i=k(n);r instanceof S?e.reportError(r):e.reportError(new S(`Expected value of type "${i}", found ${ft(t)}; `+r.message,{nodes:t,originalError:r}))}}function $i(e,t,n,r,i){let a=Object.keys(r);if(a.length!==1){e.reportError(new S(`OneOf Input Object "${n.name}" must specify exactly one key.`,{nodes:[t]}));return}let o=r[a[0]]?.value,s=!o||o.kind===E.NULL,c=o?.kind===E.VARIABLE;if(s){e.reportError(new S(`Field "${n.name}.${a[0]}" must be non-null.`,{nodes:[t]}));return}if(c){let r=o.name.value;i[r].type.kind!==E.NON_NULL_TYPE&&e.reportError(new S(`Variable "${r}" must be non-nullable to be used for OneOf Input Object "${n.name}".`,{nodes:[t]}))}}function ea(e){return{VariableDefinition(t){let n=pr(e.getSchema(),t.type);if(n!==void 0&&!Ot(n)){let n=t.variable.name.value,r=ft(t.type);e.reportError(new S(`Variable "$${n}" cannot be non-input type "${r}".`,{nodes:t.type}))}}}}function ta(e){let t=Object.create(null);return{OperationDefinition:{enter(){t=Object.create(null)},leave(n){let r=e.getRecursiveVariableUsages(n);for(let{node:n,type:i,defaultValue:a,parentType:o}of r){let r=n.name.value,s=t[r];if(s&&i){let t=e.getSchema(),c=pr(t,s.type);if(c&&!na(t,c,s.defaultValue,i,a)){let t=k(c),a=k(i);e.reportError(new S(`Variable "$${r}" of type "${t}" used in position expecting type "${a}".`,{nodes:[s,n]}))}Et(o)&&o.isOneOf&&Ft(c)&&e.reportError(new S(`Variable "$${r}" is of type "${c}" but must be non-nullable to be used for OneOf Input Object "${o}".`,{nodes:[s,n]}))}}}},VariableDefinition(e){t[e.variable.name.value]=e}}}function na(e,t,n,r,i){if(M(r)&&!M(t)){if(!(n!=null&&n.kind!==E.NULL)&&i===void 0)return!1;let a=r.ofType;return sn(e,t,a)}return sn(e,t,r)}const ra=Object.freeze([zr]),ia=Object.freeze([Cr,qi,Lr,Ii,Pr,Dr,ea,yi,wr,Gi,Nr,Hr,ui,Br,Xi,Vr,Ur,Ar,Vi,Or,zi,Zi,gi,ta,qr,Ki,...ra]),aa=Object.freeze([Rr,Ji,Yi,Hi,Ui,Ri,Bi,Pr,Ar,Vi,fi,kr,zi,Ki,_i]);var oa=class{constructor(e,t){this._ast=e,this._fragments=void 0,this._fragmentSpreads=new Map,this._recursivelyReferencedFragments=new Map,this._onError=t}get[Symbol.toStringTag](){return`ASTValidationContext`}reportError(e){this._onError(e)}getDocument(){return this._ast}getFragment(e){let t;if(this._fragments)t=this._fragments;else{t=Object.create(null);for(let e of this.getDocument().definitions)e.kind===E.FRAGMENT_DEFINITION&&(t[e.name.value]=e);this._fragments=t}return t[e]}getFragmentSpreads(e){let t=this._fragmentSpreads.get(e);if(!t){t=[];let n=[e],r;for(;r=n.pop();)for(let e of r.selections)e.kind===E.FRAGMENT_SPREAD?t.push(e):e.selectionSet&&n.push(e.selectionSet);this._fragmentSpreads.set(e,t)}return t}getRecursivelyReferencedFragments(e){let t=this._recursivelyReferencedFragments.get(e);if(!t){t=[];let n=Object.create(null),r=[e.selectionSet],i;for(;i=r.pop();)for(let e of this.getFragmentSpreads(i)){let i=e.name.value;if(n[i]!==!0){n[i]=!0;let e=this.getFragment(i);e&&(t.push(e),r.push(e.selectionSet))}}this._recursivelyReferencedFragments.set(e,t)}return t}},sa=class extends oa{constructor(e,t,n){super(e,n),this._schema=t}get[Symbol.toStringTag](){return`SDLValidationContext`}getSchema(){return this._schema}},ca=class extends oa{constructor(e,t,n,r){super(t,r),this._schema=e,this._typeInfo=n,this._variableUsages=new Map,this._recursiveVariableUsages=new Map}get[Symbol.toStringTag](){return`ValidationContext`}getSchema(){return this._schema}getVariableUsages(e){let t=this._variableUsages.get(e);if(!t){let n=[],r=new mr(this._schema);lt(e,gr(r,{VariableDefinition:()=>!1,Variable(e){n.push({node:e,type:r.getInputType(),defaultValue:r.getDefaultValue(),parentType:r.getParentInputType()})}})),t=n,this._variableUsages.set(e,t)}return t}getRecursiveVariableUsages(e){let t=this._recursiveVariableUsages.get(e);if(!t){t=this.getVariableUsages(e);for(let n of this.getRecursivelyReferencedFragments(e))t=t.concat(this.getVariableUsages(n));this._recursiveVariableUsages.set(e,t)}return t}getType(){return this._typeInfo.getType()}getParentType(){return this._typeInfo.getParentType()}getInputType(){return this._typeInfo.getInputType()}getParentInputType(){return this._typeInfo.getParentInputType()}getFieldDef(){return this._typeInfo.getFieldDef()}getDirective(){return this._typeInfo.getDirective()}getArgument(){return this._typeInfo.getArgument()}getEnumValue(){return this._typeInfo.getEnumValue()}};function la(e,t,n=ia,r,i=new mr(e)){let a=r?.maxErrors??100;t||p(!1,`Must provide document.`),Jn(e);let o=Object.freeze({}),s=[],c=new ca(e,t,i,e=>{if(s.length>=a)throw s.push(new S(`Too many validation errors, error limit reached. Validation aborted.`)),o;s.push(e)}),l=ut(n.map(e=>e(c)));try{lt(t,gr(i,l))}catch(e){if(e!==o)throw e}return s}function ua(e,t,n=aa){let r=[],i=new sa(e,t,e=>{r.push(e)});return lt(e,ut(n.map(e=>e(i)))),r}function da(e){let t=ua(e);if(t.length!==0)throw Error(t.map(e=>e.message).join(`
53
+
54
+ `))}function fa(e){return e instanceof Error?e:new pa(e)}var pa=class extends Error{constructor(e){super(`Unexpected error value: `+k(e)),this.name=`NonErrorThrown`,this.thrownValue=e}};function ma(e,t,n){let r=fa(e);return ha(r)?r:new S(r.message,{nodes:r.nodes??t,source:r.source,positions:r.positions,path:n,originalError:r})}function ha(e){return Array.isArray(e.path)}const ga=function(e,t,n,r){if(m(e)||typeof e==`function`){let i=e[r.fieldName];return typeof i==`function`?e[r.fieldName](t,n,r):i}};function _a(e,t){let n=null;for(let r of e.definitions)if(r.kind===E.OPERATION_DEFINITION){if(t==null){if(n)return null;n=r}else if(r.name?.value===t)return r}return n}function va(e,t,n){let r=[],i=Object.create(null),a=[],o,s=[];for(let e of t.definitions)if(e.kind===E.SCHEMA_DEFINITION)o=e;else if(e.kind===E.SCHEMA_EXTENSION)s.push(e);else if(br(e))r.push(e);else if(Sr(e)){let t=e.name.value,n=i[t];i[t]=n?n.concat([e]):[e]}else e.kind===E.DIRECTIVE_DEFINITION&&a.push(e);if(Object.keys(i).length===0&&r.length===0&&a.length===0&&s.length===0&&o==null)return e;let c=Object.create(null);for(let t of e.types)c[t.name]=p(t);for(let e of r){let t=e.name.value;c[t]=ya[t]??se(e)}let l={query:e.query&&d(e.query),mutation:e.mutation&&d(e.mutation),subscription:e.subscription&&d(e.subscription),...o&&C([o]),...C(s)};return{description:o?.description?.value,...l,types:Object.values(c),directives:[...e.directives.map(f),...a.map(te)],extensions:Object.create(null),astNode:o??e.astNode,extensionASTNodes:e.extensionASTNodes.concat(s),assumeValid:n?.assumeValid??!1};function u(e){return Dt(e)?new Nt(u(e.ofType)):M(e)?new N(u(e.ofType)):d(e)}function d(e){return c[e.name]}function f(e){let t=e.toConfig();return new vn({...t,args:Xe(t.args,S)})}function p(e){if(Hn(e)||hn(e))return e;if(St(e))return _(e);if(j(e))return v(e);if(Ct(e))return y(e);if(wt(e))return b(e);if(Tt(e))return g(e);if(Et(e))return m(e);h(!1,`Unexpected type: `+k(e))}function m(e){let t=e.toConfig(),n=i[t.name]??[];return new nn({...t,fields:()=>({...Xe(t.fields,e=>({...e,type:u(e.type)})),...ie(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}function g(e){let t=e.toConfig(),n=i[e.name]??[];return new $t({...t,values:{...t.values,...ae(n)},extensionASTNodes:t.extensionASTNodes.concat(n)})}function _(e){let t=e.toConfig(),n=i[t.name]??[],r=t.specifiedByURL;for(let e of n)r=xa(e)??r;return new Vt({...t,specifiedByURL:r,extensionASTNodes:t.extensionASTNodes.concat(n)})}function v(e){let t=e.toConfig(),n=i[t.name]??[];return new Ht({...t,interfaces:()=>[...e.getInterfaces().map(d),...T(n)],fields:()=>({...Xe(t.fields,x),...ne(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}function y(e){let t=e.toConfig(),n=i[t.name]??[];return new Xt({...t,interfaces:()=>[...e.getInterfaces().map(d),...T(n)],fields:()=>({...Xe(t.fields,x),...ne(n)}),extensionASTNodes:t.extensionASTNodes.concat(n)})}function b(e){let t=e.toConfig(),n=i[t.name]??[];return new Zt({...t,types:()=>[...e.getTypes().map(d),...oe(n)],extensionASTNodes:t.extensionASTNodes.concat(n)})}function x(e){return{...e,type:u(e.type),args:e.args&&Xe(e.args,S)}}function S(e){return{...e,type:u(e.type)}}function C(e){let t={};for(let n of e){let e=n.operationTypes??[];for(let n of e)t[n.operation]=w(n.type)}return t}function w(e){let t=e.name.value,n=ya[t]??c[t];if(n===void 0)throw Error(`Unknown type: "${t}".`);return n}function ee(e){return e.kind===E.LIST_TYPE?new Nt(ee(e.type)):e.kind===E.NON_NULL_TYPE?new N(ee(e.type)):w(e)}function te(e){return new vn({name:e.name.value,description:e.description?.value,locations:e.locations.map(({value:e})=>e),isRepeatable:e.repeatable,args:re(e.arguments),astNode:e})}function ne(e){let t=Object.create(null);for(let n of e){let e=n.fields??[];for(let n of e)t[n.name.value]={type:ee(n.type),description:n.description?.value,args:re(n.arguments),deprecationReason:ba(n),astNode:n}}return t}function re(e){let t=e??[],n=Object.create(null);for(let e of t){let t=ee(e.type);n[e.name.value]={type:t,description:e.description?.value,defaultValue:Ei(e.defaultValue,t),deprecationReason:ba(e),astNode:e}}return n}function ie(e){let t=Object.create(null);for(let n of e){let e=n.fields??[];for(let n of e){let e=ee(n.type);t[n.name.value]={type:e,description:n.description?.value,defaultValue:Ei(n.defaultValue,e),deprecationReason:ba(n),astNode:n}}}return t}function ae(e){let t=Object.create(null);for(let n of e){let e=n.values??[];for(let n of e)t[n.name.value]={description:n.description?.value,deprecationReason:ba(n),astNode:n}}return t}function T(e){return e.flatMap(e=>e.interfaces?.map(w)??[])}function oe(e){return e.flatMap(e=>e.types?.map(w)??[])}function se(e){let t=e.name.value,n=i[t]??[];switch(e.kind){case E.OBJECT_TYPE_DEFINITION:{let r=[e,...n];return new Ht({name:t,description:e.description?.value,interfaces:()=>T(r),fields:()=>ne(r),astNode:e,extensionASTNodes:n})}case E.INTERFACE_TYPE_DEFINITION:{let r=[e,...n];return new Xt({name:t,description:e.description?.value,interfaces:()=>T(r),fields:()=>ne(r),astNode:e,extensionASTNodes:n})}case E.ENUM_TYPE_DEFINITION:{let r=[e,...n];return new $t({name:t,description:e.description?.value,values:ae(r),astNode:e,extensionASTNodes:n})}case E.UNION_TYPE_DEFINITION:{let r=[e,...n];return new Zt({name:t,description:e.description?.value,types:()=>oe(r),astNode:e,extensionASTNodes:n})}case E.SCALAR_TYPE_DEFINITION:return new Vt({name:t,description:e.description?.value,specifiedByURL:xa(e),astNode:e,extensionASTNodes:n});case E.INPUT_OBJECT_TYPE_DEFINITION:{let r=[e,...n];return new nn({name:t,description:e.description?.value,fields:()=>ie(r),astNode:e,extensionASTNodes:n,isOneOf:Sa(e)})}}}}const ya=Je([...mn,...Vn],e=>e.name);function ba(e){return ki(xn,e)?.reason}function xa(e){return ki(Sn,e)?.url}function Sa(e){return!!ki(Cn,e)}function Ca(e,t){e!=null&&e.kind===E.DOCUMENT||p(!1,`Must provide valid Document AST.`),t?.assumeValid!==!0&&t?.assumeValidSDL!==!0&&da(e);let n=va({description:void 0,types:[],directives:[],extensions:Object.create(null),extensionASTNodes:[],assumeValid:!1},e,t);if(n.astNode==null)for(let e of n.types)switch(e.name){case`Query`:n.query=e;break;case`Mutation`:n.mutation=e;break;case`Subscription`:n.subscription=e;break}let r=[...n.directives,...wn.filter(e=>n.directives.every(t=>t.name!==e.name))];return new Gn({...n,directives:r})}function wa(e,t){return Ca(He(e,{noLocation:t?.noLocation,allowLegacyFragmentVariables:t?.allowLegacyFragmentVariables}),{assumeValidSDL:t?.assumeValidSDL,assumeValid:t?.assumeValid})}const Ta=e=>Array.isArray(e)?e:e?[e]:[];function Ea(e,t){return String(e)<String(t)?-1:+(String(e)>String(t))}function Da(e){let t;return`alias`in e&&(t=e.alias?.value),t==null&&`name`in e&&(t=e.name?.value),t??=e.kind,t}function Oa(e,t,n){let r=Da(e),i=Da(t);return typeof n==`function`?n(r,i):Ea(r,i)}function ka(e){return e!=null}function Aa(e){return ja(e,[])}function ja(e,t){switch(typeof e){case`string`:return JSON.stringify(e);case`function`:return e.name?`[function ${e.name}]`:`[function]`;case`object`:return Na(e,t);default:return String(e)}}function Ma(e){return(e.name=`GraphQLError`)?e.toString():`${e.name}: ${e.message};\n ${e.stack}`}function Na(e,t){if(e===null)return`null`;if(e instanceof Error)return e.name===`AggregateError`?Ma(e)+`
55
+ `+Ia(e.errors,t):Ma(e);if(t.includes(e))return`[Circular]`;let n=[...t,e];if(Pa(e)){let t=e.toJSON();if(t!==e)return typeof t==`string`?t:ja(t,n)}else if(Array.isArray(e))return Ia(e,n);return Fa(e,n)}function Pa(e){return typeof e.toJSON==`function`}function Fa(e,t){let n=Object.entries(e);return n.length===0?`{}`:t.length>3?`[`+La(e)+`]`:`{ `+n.map(([e,n])=>e+`: `+ja(n,t)).join(`, `)+` }`}function Ia(e,t){if(e.length===0)return`[]`;if(t.length>3)return`[Array]`;let n=e.length,r=[];for(let i=0;i<n;++i)r.push(ja(e[i],t));return`[`+r.join(`, `)+`]`}function La(e){let t=Object.prototype.toString.call(e).replace(/^\[object /,``).replace(/]$/,``);if(t===`Object`&&typeof e.constructor==`function`){let t=e.constructor.name;if(typeof t==`string`&&t!==``)return t}return t}const Ra=[`message`,`locations`,`path`,`nodes`,`source`,`positions`,`originalError`,`name`,`stack`,`extensions`];function za(e){return typeof e==`object`&&!!e&&Object.keys(e).every(e=>Ra.includes(e))}function P(e,t){return t?.originalError&&!(t.originalError instanceof Error)&&za(t.originalError)&&(t.originalError=P(t.originalError.message,t.originalError)),f.major>=17?new S(e,t):new S(e,t?.nodes,t?.source,t?.positions,t?.path,t?.originalError,t?.extensions)}const Ba=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function Va(e){return e?.then!=null}function eee(e){let t=e;return t&&t.then&&t.catch&&t.finally}function F(e,t,n,r){let i=Ha().then(e).then(t,n);return r&&(i=i.finally(r)),Qa(i)}function Ha(e){return e&&eee(e)?e:Va(e)?{then:(t,n)=>Ha(e.then(t,n)),catch:t=>Ha(e.then(e=>e,t)),finally:t=>Ha(t?Za(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return Ha(t(e))}catch(e){return Ga(e)}return this},catch(){return this},finally(t){if(t)try{return Ha(t()).then(()=>e,()=>e)}catch(e){return Ga(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[Ba]:`resolved`}}function Ua(){if(Promise.withResolvers)return Promise.withResolvers();let e,t;return{promise:new Promise(function(n,r){e=n,t=r}),get resolve(){return e},get reject(){return t}}}function Wa(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),i=0;function a(){let{done:e,value:o}=r.next();if(e)return;let s=!1;function c(){s=!0}return F(function(){return t(o,c,i++)},function(e){if(e&&n?.push(e),!s)return a()})}return a()}function Ga(e){return{then(t,n){if(n)try{return Ha(n(e))}catch(e){return Ga(e)}return this},catch(t){if(t)try{return Ha(t(e))}catch(e){return Ga(e)}return this},finally(e){if(e)try{e()}catch(e){return Ga(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[Ba]:`rejected`}}function Ka(e,t,n){return F(()=>e,t,n)}function qa(e,t,n,r){Symbol.asyncIterator in e&&(e=e[Symbol.asyncIterator]());let i,a,o;if(r){let e;o=t=>(e||=F(r,()=>t,()=>t),e)}typeof e.return==`function`&&(i=e.return,a=t=>{let n=()=>{throw t};return i.call(e).then(n,n)});function s(e){return e.done?o?o(e):e:F(()=>e.value,e=>F(()=>t(e),Ja,a))}let c;if(n){let e,t=n;c=n=>(e||=F(()=>n,e=>F(()=>t(e),Ja,a)),e)}return{next(){return e.next().then(s,c)},return(){let t=i?i.call(e).then(s,c):Ha({value:void 0,done:!0});return o?t.then(o):t},throw(t){return typeof e.throw==`function`?e.throw(t).then(s,c):a?a(t):Ga(t)},[Symbol.asyncIterator](){return this}}}function Ja(e){return{value:e,done:!1}}function Ya(e){return e?.[Ba]===`resolved`}function Xa(e){return e?.[Ba]===`rejected`}function Za(e,t){return`finally`in e?e.finally(t):e.then(e=>{let n=t();return Va(n)?n.then(()=>e):e},e=>{let n=t();if(Va(n))return n.then(()=>{throw e});throw e})}function Qa(e){if(Ya(e))return e.__fakePromiseValue;if(Xa(e))throw e.__fakeRejectError;return e}function $a(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function eo(e){return typeof e==`object`&&!!e}function to(e,t,n){let r=n;for(let n of e)r=F(()=>r,e=>t(e,n));return r}function no(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function ro(e,t,n={}){let r={},i=(t.arguments??[]).reduce((e,t)=>({...e,[t.name.value]:t}),{});for(let{name:a,type:o,defaultValue:s}of e.args){let e=i[a];if(!e){if(s!==void 0)r[a]=s;else if(M(o))throw P(`Argument "${a}" of required type "${Aa(o)}" was not provided.`,{nodes:[t]});continue}let c=e.value,l=c.kind===E.NULL;if(c.kind===E.VARIABLE){let e=c.name.value;if(n==null||!no(n,e)){if(s!==void 0)r[a]=s;else if(M(o))throw P(`Argument "${a}" of required type "${Aa(o)}" was provided the variable "$${e}" which was not provided a runtime value.`,{nodes:[c]});continue}l=n[e]==null}if(l&&M(o))throw P(`Argument "${a}" of non-null type "${Aa(o)}" must not be null.`,{nodes:[c]});let u=Ei(c,o,n);if(u===void 0)throw P(`Argument "${a}" has invalid value ${ft(c)}.`,{nodes:[c]});r[a]=u}return r}function io(e){let t=new WeakMap;return function(n){let r=t.get(n);if(r===void 0){let r=e(n);return t.set(n,r),r}return r}}function ao(e){let t=new WeakMap;return function(n,r,i){let a=t.get(n);if(!a){a=new WeakMap,t.set(n,a);let o=new WeakMap;a.set(r,o);let s=e(n,r,i);return o.set(i,s),s}let o=a.get(r);if(!o){o=new WeakMap,a.set(r,o);let t=e(n,r,i);return o.set(i,t),t}let s=o.get(i);if(s===void 0){let t=e(n,r,i);return o.set(i,t),t}return s}}function oo(e){let t=new WeakMap;return function(n,r,i,a){let o=t.get(n);if(!o){o=new WeakMap,t.set(n,o);let s=new WeakMap;o.set(r,s);let c=new WeakMap;s.set(i,c);let l=e(n,r,i,a);return c.set(a,l),l}let s=o.get(r);if(!s){s=new WeakMap,o.set(r,s);let t=new WeakMap;s.set(i,t);let c=e(n,r,i,a);return t.set(a,c),c}let c=s.get(i);if(!c){let t=new WeakMap;s.set(i,t);let o=e(n,r,i,a);return t.set(a,o),o}let l=c.get(a);if(l===void 0){let t=e(n,r,i,a);return c.set(a,t),t}return l}}function so(e){let t=new WeakMap;return function(n,r,i,a,o){let s=t.get(n);if(!s){s=new WeakMap,t.set(n,s);let c=new WeakMap;s.set(r,c);let l=new WeakMap;c.set(i,l);let u=new WeakMap;l.set(a,u);let d=e(n,r,i,a,o);return u.set(o,d),d}let c=s.get(r);if(!c){c=new WeakMap,s.set(r,c);let t=new WeakMap;c.set(i,t);let l=new WeakMap;t.set(a,l);let u=e(n,r,i,a,o);return l.set(o,u),u}let l=c.get(i);if(!l){l=new WeakMap,c.set(i,l);let t=new WeakMap;l.set(a,t);let s=e(n,r,i,a,o);return t.set(o,s),s}let u=l.get(a);if(!u){u=new WeakMap,l.set(a,u);let t=e(n,r,i,a,o);return u.set(o,t),t}let d=u.get(o);if(d===void 0){let t=e(n,r,i,a,o);return u.set(o,t),t}return d}}function co(e,t,n=[`directives`]){let r={};if(e.extensions){let t=e.extensions;for(let e of n)t=t?.[e];if(t!=null)for(let e in t){let n=t[e],i=e;if(Array.isArray(n))for(let e of n){let t=r[i];t||(t=[],r[i]=t),t.push(e)}else{let e=r[i];e||(e=[],r[i]=e),e.push(n)}}}let i=io(e=>JSON.stringify(e)),a=[];e.astNode&&a.push(e.astNode),e.extensionASTNodes&&a.push(...e.extensionASTNodes);for(let e of a)if(e.directives?.length)for(let n of e.directives){let e=n.name.value,o=r[e];o||(o=[],r[e]=o);let s=t?.getDirective(e),c={};if(s&&(c=ro(s,n)),n.arguments)for(let e of n.arguments){let t=e.name.value;if(c[t]==null){let n=s?.args.find(e=>e.name===t);n&&(c[t]=Ei(e.value,n.type))}c[t]??(c[t]=vt(e.value))}if(a.length>0&&o.length>0){let e=i(c);if(o.some(t=>i(t)===e))continue}o.push(c)}return r}function lo(e,t=[`directives`]){let n=co(e,void 0,t);return Object.entries(n).map(([e,t])=>t?.map(t=>({name:e,args:t}))).flat(1/0).filter(Boolean)}function uo(e,t,n,r=[`directives`]){return co(t,e,r)[n]}function fo(e){if(M(e)){let t=fo(e.ofType);if(t.kind===E.NON_NULL_TYPE)throw Error(`Invalid type node ${Aa(e)}. Inner type of non-null type cannot be a non-null type.`);return{kind:E.NON_NULL_TYPE,type:t}}else if(Dt(e))return{kind:E.LIST_TYPE,type:fo(e.ofType)};return{kind:E.NAMED_TYPE,name:{kind:E.NAME,value:e.name}}}function po(e){if(e===null)return{kind:E.NULL};if(e===void 0)return null;if(Array.isArray(e)){let t=[];for(let n of e){let e=po(n);e!=null&&t.push(e)}return{kind:E.LIST,values:t}}if(typeof e==`object`){if(e?.toJSON)return po(e.toJSON());let t=[];for(let n in e){let r=e[n],i=po(r);i&&t.push({kind:E.OBJECT_FIELD,name:{kind:E.NAME,value:n},value:i})}return{kind:E.OBJECT,fields:t}}if(typeof e==`boolean`)return{kind:E.BOOLEAN,value:e};if(typeof e==`bigint`)return{kind:E.INT,value:String(e)};if(typeof e==`number`&&isFinite(e)){let t=String(e);return mo.test(t)?{kind:E.INT,value:t}:{kind:E.FLOAT,value:t}}if(typeof e==`string`)return{kind:E.STRING,value:e};throw TypeError(`Cannot convert value to AST: ${e}.`)}const mo=/^-?(?:0|[1-9][0-9]*)$/;function ho(e,t){if(M(t)){let n=ho(e,t.ofType);return n?.kind===E.NULL?null:n}if(e===null)return{kind:E.NULL};if(e===void 0)return null;if(Dt(t)){let n=t.ofType;if($a(e)){let t=[];for(let r of e){let e=ho(r,n);e!=null&&t.push(e)}return{kind:E.LIST,values:t}}return ho(e,n)}if(Et(t)){if(!eo(e))return null;let n=[];for(let r of Object.values(t.getFields())){let t=ho(e[r.name],r.type);t&&n.push({kind:E.OBJECT_FIELD,name:{kind:E.NAME,value:r.name},value:t})}return{kind:E.OBJECT,fields:n}}if(At(t)){let n=t.serialize(e);return n==null?null:Tt(t)?{kind:E.ENUM,value:n}:t.name===`ID`&&typeof n==`string`&&go.test(n)?{kind:E.INT,value:n}:po(n)}console.assert(!1,`Unexpected input type: `+Aa(t))}const go=/^-?(?:0|[1-9][0-9]*)$/;function _o(e){if(e.astNode?.description)return{...e.astNode.description,block:!0};if(e.description)return{kind:E.STRING,value:e.description,block:!0}}function vo(e,t,n){let r=yo(e).get(t);if(r==null)throw P(`Schema is not configured to execute ${t} operation.`,{nodes:n});return r}const yo=io(function(e){let t=new Map,n=e.getQueryType();n&&t.set(`query`,n);let r=e.getMutationType();r&&t.set(`mutation`,r);let i=e.getSubscriptionType();return i&&t.set(`subscription`,i),t});function bo(e,t={}){let n=t.pathToDirectivesInExtensions,r=e.getTypeMap(),i=xo(e,n),a=i==null?[]:[i],o=e.getDirectives();for(let t of o)Tn(t)||a.push(So(t,e,n));for(let t in r){let i=r[t],o=hn(i),s=Hn(i);if(!(o||s))if(j(i))a.push(To(i,e,n));else if(Ct(i))a.push(Eo(i,e,n));else if(wt(i))a.push(Do(i,e,n));else if(Et(i))a.push(Oo(i,e,n));else if(Tt(i))a.push(ko(i,e,n));else if(St(i))a.push(Ao(i,e,n));else throw Error(`Unknown type ${i}.`)}return{kind:E.DOCUMENT,definitions:a}}function xo(e,t){let n=new Map([[`query`,void 0],[`mutation`,void 0],[`subscription`,void 0]]),r=[];if(e.astNode!=null&&r.push(e.astNode),e.extensionASTNodes!=null)for(let t of e.extensionASTNodes)r.push(t);for(let e of r)if(e.operationTypes)for(let t of e.operationTypes)n.set(t.operation,t);let i=yo(e);for(let[e,t]of n){let r=i.get(e);if(r!=null){let i=fo(r);t==null?n.set(e,{kind:E.OPERATION_TYPE_DEFINITION,operation:e,type:i}):t.type=i}}let a=[...n.values()].filter(ka),o=Co(e,e,t);if(!a.length&&!o.length)return null;let s={kind:a==null?E.SCHEMA_EXTENSION:E.SCHEMA_DEFINITION,operationTypes:a,directives:o},c=_o(e);return c&&(s.description=c),s}function So(e,t,n){return{kind:E.DIRECTIVE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},arguments:e.args?.map(e=>wo(e,t,n)),repeatable:e.isRepeatable,locations:e.locations?.map(e=>({kind:E.NAME,value:e}))||[]}}function Co(e,t,n){let r=[],i=lo(e,n),a;i!=null&&(a=Io(t,i));let o=null,s=null,c=null;return a!=null&&(r=a.filter(e=>wn.every(t=>t.name!==e.name.value)),o=a.find(e=>e.name.value===`deprecated`),s=a.find(e=>e.name.value===`specifiedBy`),c=a.find(e=>e.name.value===`oneOf`)),e.deprecationReason!=null&&o==null&&(o=Po(e.deprecationReason)),(e.specifiedByUrl!=null||e.specifiedByURL!=null&&s==null)&&(s=Fo(`specifiedBy`,{url:e.specifiedByUrl||e.specifiedByURL})),e.isOneOf&&c==null&&(c=Fo(`oneOf`)),o!=null&&r.push(o),s!=null&&r.push(s),c!=null&&r.push(c),r}function wo(e,t,n){return{kind:E.INPUT_VALUE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},type:fo(e.type),defaultValue:e.defaultValue===void 0?void 0:ho(e.defaultValue,e.type)??void 0,directives:Co(e,t,n)}}function To(e,t,n){return{kind:E.OBJECT_TYPE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},fields:Object.values(e.getFields()).map(e=>jo(e,t,n)),interfaces:Object.values(e.getInterfaces()).map(e=>fo(e)),directives:Co(e,t,n)}}function Eo(e,t,n){let r={kind:E.INTERFACE_TYPE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},fields:Object.values(e.getFields()).map(e=>jo(e,t,n)),directives:Co(e,t,n)};return`getInterfaces`in e&&(r.interfaces=Object.values(e.getInterfaces()).map(e=>fo(e))),r}function Do(e,t,n){return{kind:E.UNION_TYPE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},directives:Co(e,t,n),types:e.getTypes().map(e=>fo(e))}}function Oo(e,t,n){return{kind:E.INPUT_OBJECT_TYPE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},fields:Object.values(e.getFields()).map(e=>Mo(e,t,n)),directives:Co(e,t,n)}}function ko(e,t,n){return{kind:E.ENUM_TYPE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},values:Object.values(e.getValues()).map(e=>No(e,t,n)),directives:Co(e,t,n)}}function Ao(e,t,n){let r=Io(t,lo(e,n)),i=e.specifiedByUrl||e.specifiedByURL;if(i&&!r.some(e=>e.name.value===`specifiedBy`)){let e={url:i};r.push(Fo(`specifiedBy`,e))}return{kind:E.SCALAR_TYPE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},directives:r}}function jo(e,t,n){return{kind:E.FIELD_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},arguments:e.args.map(e=>wo(e,t,n)),type:fo(e.type),directives:Co(e,t,n)}}function Mo(e,t,n){return{kind:E.INPUT_VALUE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},type:fo(e.type),directives:Co(e,t,n),defaultValue:ho(e.defaultValue,e.type)??void 0}}function No(e,t,n){return{kind:E.ENUM_VALUE_DEFINITION,description:_o(e),name:{kind:E.NAME,value:e.name},directives:Co(e,t,n)}}function Po(e){return Fo(`deprecated`,{reason:e},xn)}function Fo(e,t,n){let r=[];for(let e in t){let i=t[e],a;if(n!=null){let t=n.args.find(t=>t.name===e);t&&(a=ho(i,t.type))}a??=po(i),a!=null&&r.push({kind:E.ARGUMENT,name:{kind:E.NAME,value:e},value:a})}return{kind:E.DIRECTIVE,name:{kind:E.NAME,value:e},arguments:r}}function Io(e,t){let n=[];for(let{name:r,args:i}of t){let t=e?.getDirective(r);n.push(Fo(r,i,t))}return n}let Lo={};function Ro(){Lo={}}function zo(e){let t=e.name?.value;if(t!=null)switch(Bo(e,t),e.kind){case`EnumTypeDefinition`:if(e.values)for(let n of e.values)Bo(n,t,n.name.value);break;case`ObjectTypeDefinition`:case`InputObjectTypeDefinition`:case`InterfaceTypeDefinition`:if(e.fields){for(let n of e.fields)if(Bo(n,t,n.name.value),Zo(n)&&n.arguments)for(let e of n.arguments)Bo(e,t,n.name.value,e.name.value)}break}}function Bo(e,t,n,r){let i=Qo(e);if(typeof i!=`string`||i.length===0)return;let a=[t];n&&(a.push(n),r&&a.push(r));let o=a.join(`.`);Lo[o]||(Lo[o]=[]),Lo[o].push(i)}function Vo(e){return`
56
+ # `+e.replace(/\n/g,`
57
+ # `)}function I(e,t){return e?e.filter(e=>e).join(t||``):``}function Ho(e){return e?.some(e=>e.includes(`
58
+ `))??!1}function Uo(e){return(t,n,r,i,a)=>{let o=[],s=i.reduce((e,t)=>([`fields`,`arguments`,`values`].includes(t)&&e.name&&o.push(e.name.value),e[t]),a[0]),c=[...o,s?.name?.value].filter(Boolean).join(`.`),l=[];return t.kind.includes(`Definition`)&&Lo[c]&&l.push(...Lo[c]),I([...l.map(Vo),t.description,e(t,n,r,i,a)],`
59
+ `)}}function Wo(e){return e&&` ${e.replace(/\n/g,`
60
+ `)}`}function Go(e){return e&&e.length!==0?`{\n${Wo(I(e,`
61
+ `))}\n}`:``}function Ko(e,t,n){return t?e+t+(n||``):``}function qo(e,t=!1){let n=e.replace(/\\/g,`\\\\`).replace(/"""/g,`\\"""`);return(e[0]===` `||e[0]===` `)&&e.indexOf(`
62
+ `)===-1?`"""${n.replace(/"$/,`"
63
+ `)}"""`:`"""\n${t?n:Wo(n)}\n"""`}const Jo={Name:{leave:e=>e.value},Variable:{leave:e=>`$`+e.name},Document:{leave:e=>I(e.definitions,`
64
+
65
+ `)},OperationDefinition:{leave:e=>{let t=Ko(`(`,I(e.variableDefinitions,`, `),`)`);return I([e.operation,I([e.name,t]),I(e.directives,` `)],` `)+` `+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:t,defaultValue:n,directives:r})=>e+`: `+t+Ko(` = `,n)+Ko(` `,I(r,` `))},SelectionSet:{leave:({selections:e})=>Go(e)},Field:{leave({alias:e,name:t,arguments:n,directives:r,selectionSet:i}){let a=Ko(``,e,`: `)+t,o=a+Ko(`(`,I(n,`, `),`)`);return o.length>80&&(o=a+Ko(`(
66
+ `,Wo(I(n,`
67
+ `)),`
68
+ )`)),I([o,I(r,` `),i],` `)}},Argument:{leave:({name:e,value:t})=>e+`: `+t},FragmentSpread:{leave:({name:e,directives:t})=>`...`+e+Ko(` `,I(t,` `))},InlineFragment:{leave:({typeCondition:e,directives:t,selectionSet:n})=>I([`...`,Ko(`on `,e),I(t,` `),n],` `)},FragmentDefinition:{leave:({name:e,typeCondition:t,variableDefinitions:n,directives:r,selectionSet:i})=>`fragment ${e}${Ko(`(`,I(n,`, `),`)`)} on ${t} ${Ko(``,I(r,` `),` `)}`+i},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:t})=>t?qo(e):JSON.stringify(e)},BooleanValue:{leave:({value:e})=>e?`true`:`false`},NullValue:{leave:()=>`null`},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>`[`+I(e,`, `)+`]`},ObjectValue:{leave:({fields:e})=>`{`+I(e,`, `)+`}`},ObjectField:{leave:({name:e,value:t})=>e+`: `+t},Directive:{leave:({name:e,arguments:t})=>`@`+e+Ko(`(`,I(t,`, `),`)`)},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>`[`+e+`]`},NonNullType:{leave:({type:e})=>e+`!`},SchemaDefinition:{leave:({directives:e,operationTypes:t})=>I([`schema`,I(e,` `),Go(t)],` `)},OperationTypeDefinition:{leave:({operation:e,type:t})=>e+`: `+t},ScalarTypeDefinition:{leave:({name:e,directives:t})=>I([`scalar`,e,I(t,` `)],` `)},ObjectTypeDefinition:{leave:({name:e,interfaces:t,directives:n,fields:r})=>I([`type`,e,Ko(`implements `,I(t,` & `)),I(n,` `),Go(r)],` `)},FieldDefinition:{leave:({name:e,arguments:t,type:n,directives:r})=>e+(Ho(t)?Ko(`(
69
+ `,Wo(I(t,`
70
+ `)),`
71
+ )`):Ko(`(`,I(t,`, `),`)`))+`: `+n+Ko(` `,I(r,` `))},InputValueDefinition:{leave:({name:e,type:t,defaultValue:n,directives:r})=>I([e+`: `+t,Ko(`= `,n),I(r,` `)],` `)},InterfaceTypeDefinition:{leave:({name:e,interfaces:t,directives:n,fields:r})=>I([`interface`,e,Ko(`implements `,I(t,` & `)),I(n,` `),Go(r)],` `)},UnionTypeDefinition:{leave:({name:e,directives:t,types:n})=>I([`union`,e,I(t,` `),Ko(`= `,I(n,` | `))],` `)},EnumTypeDefinition:{leave:({name:e,directives:t,values:n})=>I([`enum`,e,I(t,` `),Go(n)],` `)},EnumValueDefinition:{leave:({name:e,directives:t})=>I([e,I(t,` `)],` `)},InputObjectTypeDefinition:{leave:({name:e,directives:t,fields:n})=>I([`input`,e,I(t,` `),Go(n)],` `)},DirectiveDefinition:{leave:({name:e,arguments:t,repeatable:n,locations:r})=>`directive @`+e+(Ho(t)?Ko(`(
72
+ `,Wo(I(t,`
73
+ `)),`
74
+ )`):Ko(`(`,I(t,`, `),`)`))+(n?` repeatable`:``)+` on `+I(r,` | `)},SchemaExtension:{leave:({directives:e,operationTypes:t})=>I([`extend schema`,I(e,` `),Go(t)],` `)},ScalarTypeExtension:{leave:({name:e,directives:t})=>I([`extend scalar`,e,I(t,` `)],` `)},ObjectTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>I([`extend type`,e,Ko(`implements `,I(t,` & `)),I(n,` `),Go(r)],` `)},InterfaceTypeExtension:{leave:({name:e,interfaces:t,directives:n,fields:r})=>I([`extend interface`,e,Ko(`implements `,I(t,` & `)),I(n,` `),Go(r)],` `)},UnionTypeExtension:{leave:({name:e,directives:t,types:n})=>I([`extend union`,e,I(t,` `),Ko(`= `,I(n,` | `))],` `)},EnumTypeExtension:{leave:({name:e,directives:t,values:n})=>I([`extend enum`,e,I(t,` `),Go(n)],` `)},InputObjectTypeExtension:{leave:({name:e,directives:t,fields:n})=>I([`extend input`,e,I(t,` `),Go(n)],` `)}},Yo=Object.keys(Jo).reduce((e,t)=>({...e,[t]:{leave:Uo(Jo[t].leave)}}),{});function Xo(e){return lt(e,Yo)}function Zo(e){return e.kind===`FieldDefinition`}function Qo(e){let t=$o(e);if(t!==void 0)return es(`\n${t}`)}function $o(e){let t=e.loc;if(!t)return;let n=[],r=t.startToken.prev;for(;r!=null&&r.kind===D.COMMENT&&r.next!=null&&r.prev!=null&&r.line+1===r.next.line&&r.line!==r.prev.line;){let e=String(r.value);n.push(e),r=r.prev}return n.length>0?n.reverse().join(`
75
+ `):void 0}function es(e){let t=e.split(/\r\n|[\n\r]/g),n=ts(t);if(n!==0)for(let e=1;e<t.length;e++)t[e]=t[e].slice(n);for(;t.length>0&&rs(t[0]);)t.shift();for(;t.length>0&&rs(t[t.length-1]);)t.pop();return t.join(`
76
+ `)}function ts(e){let t=null;for(let n=1;n<e.length;n++){let r=e[n],i=ns(r);if(i!==r.length&&(t===null||i<t)&&(t=i,t===0))break}return t===null?0:t}function ns(e){let t=0;for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;return t}function rs(e){return ns(e)===e.length}var L;(function(e){e.TYPE=`MapperKind.TYPE`,e.SCALAR_TYPE=`MapperKind.SCALAR_TYPE`,e.ENUM_TYPE=`MapperKind.ENUM_TYPE`,e.COMPOSITE_TYPE=`MapperKind.COMPOSITE_TYPE`,e.OBJECT_TYPE=`MapperKind.OBJECT_TYPE`,e.INPUT_OBJECT_TYPE=`MapperKind.INPUT_OBJECT_TYPE`,e.ABSTRACT_TYPE=`MapperKind.ABSTRACT_TYPE`,e.UNION_TYPE=`MapperKind.UNION_TYPE`,e.INTERFACE_TYPE=`MapperKind.INTERFACE_TYPE`,e.ROOT_OBJECT=`MapperKind.ROOT_OBJECT`,e.QUERY=`MapperKind.QUERY`,e.MUTATION=`MapperKind.MUTATION`,e.SUBSCRIPTION=`MapperKind.SUBSCRIPTION`,e.DIRECTIVE=`MapperKind.DIRECTIVE`,e.FIELD=`MapperKind.FIELD`,e.COMPOSITE_FIELD=`MapperKind.COMPOSITE_FIELD`,e.OBJECT_FIELD=`MapperKind.OBJECT_FIELD`,e.ROOT_FIELD=`MapperKind.ROOT_FIELD`,e.QUERY_ROOT_FIELD=`MapperKind.QUERY_ROOT_FIELD`,e.MUTATION_ROOT_FIELD=`MapperKind.MUTATION_ROOT_FIELD`,e.SUBSCRIPTION_ROOT_FIELD=`MapperKind.SUBSCRIPTION_ROOT_FIELD`,e.INTERFACE_FIELD=`MapperKind.INTERFACE_FIELD`,e.INPUT_OBJECT_FIELD=`MapperKind.INPUT_OBJECT_FIELD`,e.ARGUMENT=`MapperKind.ARGUMENT`,e.ENUM_VALUE=`MapperKind.ENUM_VALUE`})(L||={});function is(e,t){if(t){let n=e[t.name];if(j(n))return n}}function as(e){if(`getFields`in e){let t=e.getFields();for(let e in t)return t[e].name===`_fake`}return!1}function os(e){switch(e.name){case ln.name:return ln;case un.name:return un;case dn.name:return dn;case fn.name:return fn;case pn.name:return pn;default:return e}}function ss(e,t){let n=Object.create(null);for(let t in e)n[t]=e[t];let r=Object.create(null);for(let e in n){let t=n[e];if(t==null||e.startsWith(`__`))continue;let i=t.name;if(!i.startsWith(`__`)){if(r[i]!=null){console.warn(`Duplicate schema type name ${i} found; keeping the existing one found in the schema`);continue}r[i]=t}}for(let e in r)r[e]=o(r[e]);return{typeMap:r,directives:t.map(e=>i(e))};function i(e){if(Tn(e))return e;let t=e.toConfig();return t.args=a(t.args),new vn(t)}function a(e){let t={};for(let n in e){let r=e[n],i=u(r.type);i!=null&&(r.type=i,t[n]=r)}return t}function o(e){if(j(e)){let t=e.toConfig();return new Ht({...t,fields:()=>s(t.fields),interfaces:()=>l(t.interfaces)})}else if(Ct(e)){let t=e.toConfig(),n={...t,fields:()=>s(t.fields)};return`interfaces`in n&&(n.interfaces=()=>l(t.interfaces)),new Xt(n)}else if(wt(e)){let t=e.toConfig();return new Zt({...t,types:()=>l(t.types)})}else if(Et(e)){let t=e.toConfig();return new nn({...t,fields:()=>c(t.fields)})}else if(Tt(e))return new $t(e.toConfig());else if(St(e))return hn(e)?e:new Vt(e.toConfig());throw Error(`Unexpected schema type: ${e}`)}function s(e){let t={};for(let n in e){let r=e[n],i=u(r.type);i!=null&&r.args&&(r.type=i,r.args=a(r.args),t[n]=r)}return t}function c(e){let t={};for(let n in e){let r=e[n],i=u(r.type);i!=null&&(r.type=i,t[n]=r)}return t}function l(e){let t=[];for(let n of e){let e=u(n);e!=null&&t.push(e)}return t}function u(e){if(Dt(e)){let t=u(e.ofType);return t==null?null:new Nt(t)}else if(M(e)){let t=u(e.ofType);return t==null?null:new N(t)}else if(Lt(e)){let t=n[e.name];return t===void 0&&(t=as(e)?os(e):o(e),r[t.name]=n[e.name]=t),t==null?null:r[t.name]}return null}}function cs(e,t,n=null,r=null){if(t==null)return t;let i=It(e);if(At(i))return n==null?t:n(i,t);if(Dt(i))return Ta(t).map(e=>cs(i.ofType,e,n,r));if(Et(i)){let e=i.getFields(),a={};for(let i in t){let o=e[i];o!=null&&(a[i]=cs(o.type,t[i],n,r))}return r==null?a:r(i,a)}}function ls(e,t){return cs(e,t,(e,t)=>{try{return e.serialize(t)}catch{return t}})}function us(e,t){return cs(e,t,(e,t)=>{try{return e.parseValue(t)}catch{return t}})}function ds(e,t={}){let n=_s(gs(fs(ms(ps(fs(ms(e.getTypeMap(),e,ls),e,t,e=>At(e)),e,t),e,us),e,t,e=>!At(e)),e,t),e,t),{typeMap:r,directives:i}=ss(n,vs(e.getDirectives(),e,t));return new Gn({...e.toConfig(),query:is(r,is(n,e.getQueryType())),mutation:is(r,is(n,e.getMutationType())),subscription:is(r,is(n,e.getSubscriptionType())),types:Object.values(r),directives:i})}function fs(e,t,n,r=()=>!0){let i={};for(let a in e)if(!a.startsWith(`__`)){let o=e[a];if(o==null||!r(o)){i[a]=o;continue}let s=bs(t,n,a);if(s==null){i[a]=o;continue}let c=s(o,t);if(c===void 0){i[a]=o;continue}i[a]=c}return i}function ps(e,t,n){let r=Ts(n);return r?fs(e,t,{[L.ENUM_TYPE]:e=>{let n=e.toConfig(),i=n.values,a={};for(let n in i){let o=i[n],s=r(o,e.name,t,n);if(s===void 0)a[n]=o;else if(Array.isArray(s)){let[e,t]=s;a[e]=t===void 0?o:t}else s!==null&&(a[n]=s)}return Es(new $t({...n,values:a}))}},e=>Tt(e)):e}function ms(e,t,n){let r=_s(e,t,{[L.ARGUMENT]:t=>{if(t.defaultValue===void 0)return t;let r=hs(e,t.type);if(r!=null)return{...t,defaultValue:n(r,t.defaultValue)}}});return gs(r,t,{[L.INPUT_OBJECT_FIELD]:e=>{if(e.defaultValue===void 0)return e;let t=hs(r,e.type);if(t!=null)return{...e,defaultValue:n(t,e.defaultValue)}}})}function hs(e,t){if(Dt(t)){let n=hs(e,t.ofType);return n==null?null:new Nt(n)}else if(M(t)){let n=hs(e,t.ofType);return n==null?null:new N(n)}else if(Lt(t))return e[t.name]??null;return null}function gs(e,t,n){let r={};for(let i in e)if(!i.startsWith(`__`)){let a=e[i];if(!j(a)&&!Ct(a)&&!Et(a)){r[i]=a;continue}let o=Ss(t,n,i);if(o==null){r[i]=a;continue}let s=a.toConfig(),c=s.fields,l={};for(let e in c){let n=c[e],r=o(n,e,i,t);if(r===void 0)l[e]=n;else if(Array.isArray(r)){let[e,t]=r;t.astNode!=null&&(t.astNode={...t.astNode,name:{...t.astNode.name,value:e}}),l[e]=t===void 0?n:t}else r!==null&&(l[e]=r)}j(a)?r[i]=Es(new Ht({...s,fields:l})):Ct(a)?r[i]=Es(new Xt({...s,fields:l})):r[i]=Es(new nn({...s,fields:l}))}return r}function _s(e,t,n){let r={};for(let i in e)if(!i.startsWith(`__`)){let a=e[i];if(!j(a)&&!Ct(a)){r[i]=a;continue}let o=Cs(n);if(o==null){r[i]=a;continue}let s=a.toConfig(),c=s.fields,l={};for(let e in c){let n=c[e],r=n.args;if(r==null){l[e]=n;continue}let a=Object.keys(r);if(!a.length){l[e]=n;continue}let s={};for(let n of a){let a=r[n],c=o(a,e,i,t);if(c===void 0)s[n]=a;else if(Array.isArray(c)){let[e,t]=c;s[e]=t}else c!==null&&(s[n]=c)}l[e]={...n,args:s}}j(a)?r[i]=new Ht({...s,fields:l}):Ct(a)?r[i]=new Xt({...s,fields:l}):r[i]=new nn({...s,fields:l})}return r}function vs(e,t,n){let r=ws(n);if(r==null)return e.slice();let i=[];for(let n of e){let e=r(n,t);e===void 0?i.push(n):e!==null&&i.push(e)}return i}function ys(e,t){let n=e.getType(t),r=[L.TYPE];return j(n)?(r.push(L.COMPOSITE_TYPE,L.OBJECT_TYPE),t===e.getQueryType()?.name?r.push(L.ROOT_OBJECT,L.QUERY):t===e.getMutationType()?.name?r.push(L.ROOT_OBJECT,L.MUTATION):t===e.getSubscriptionType()?.name&&r.push(L.ROOT_OBJECT,L.SUBSCRIPTION)):Et(n)?r.push(L.INPUT_OBJECT_TYPE):Ct(n)?r.push(L.COMPOSITE_TYPE,L.ABSTRACT_TYPE,L.INTERFACE_TYPE):wt(n)?r.push(L.COMPOSITE_TYPE,L.ABSTRACT_TYPE,L.UNION_TYPE):Tt(n)?r.push(L.ENUM_TYPE):St(n)&&r.push(L.SCALAR_TYPE),r}function bs(e,t,n){let r=ys(e,n),i,a=[...r];for(;!i&&a.length>0;)i=t[a.pop()];return i??null}function xs(e,t){let n=e.getType(t),r=[L.FIELD];return j(n)?(r.push(L.COMPOSITE_FIELD,L.OBJECT_FIELD),t===e.getQueryType()?.name?r.push(L.ROOT_FIELD,L.QUERY_ROOT_FIELD):t===e.getMutationType()?.name?r.push(L.ROOT_FIELD,L.MUTATION_ROOT_FIELD):t===e.getSubscriptionType()?.name&&r.push(L.ROOT_FIELD,L.SUBSCRIPTION_ROOT_FIELD)):Ct(n)?r.push(L.COMPOSITE_FIELD,L.INTERFACE_FIELD):Et(n)&&r.push(L.INPUT_OBJECT_FIELD),r}function Ss(e,t,n){let r=xs(e,n),i,a=[...r];for(;!i&&a.length>0;)i=t[a.pop()];return i??null}function Cs(e){return e[L.ARGUMENT]??null}function ws(e){return e[L.DIRECTIVE]??null}function Ts(e){return e[L.ENUM_VALUE]??null}function Es(e){if(j(e)){let t=e.toConfig();if(t.astNode!=null){let e=[];for(let n in t.fields){let r=t.fields[n];r.astNode!=null&&e.push(r.astNode)}t.astNode={...t.astNode,kind:E.OBJECT_TYPE_DEFINITION,fields:e}}return t.extensionASTNodes!=null&&(t.extensionASTNodes=t.extensionASTNodes.map(e=>({...e,kind:E.OBJECT_TYPE_EXTENSION,fields:void 0}))),new Ht(t)}else if(Ct(e)){let t=e.toConfig();if(t.astNode!=null){let e=[];for(let n in t.fields){let r=t.fields[n];r.astNode!=null&&e.push(r.astNode)}t.astNode={...t.astNode,kind:E.INTERFACE_TYPE_DEFINITION,fields:e}}return t.extensionASTNodes!=null&&(t.extensionASTNodes=t.extensionASTNodes.map(e=>({...e,kind:E.INTERFACE_TYPE_EXTENSION,fields:void 0}))),new Xt(t)}else if(Et(e)){let t=e.toConfig();if(t.astNode!=null){let e=[];for(let n in t.fields){let r=t.fields[n];r.astNode!=null&&e.push(r.astNode)}t.astNode={...t.astNode,kind:E.INPUT_OBJECT_TYPE_DEFINITION,fields:e}}return t.extensionASTNodes!=null&&(t.extensionASTNodes=t.extensionASTNodes.map(e=>({...e,kind:E.INPUT_OBJECT_TYPE_EXTENSION,fields:void 0}))),new nn(t)}else if(Tt(e)){let t=e.toConfig();if(t.astNode!=null){let e=[];for(let n in t.values){let r=t.values[n];r.astNode!=null&&e.push(r.astNode)}t.astNode={...t.astNode,values:e}}return t.extensionASTNodes!=null&&(t.extensionASTNodes=t.extensionASTNodes.map(e=>({...e,values:void 0}))),new $t(t)}else return e}function Ds(e){return Os(e.getTypeMap(),e.getDirectives()),e}function Os(e,t){let n=Object.create(null);for(let t in e){let r=e[t];if(r==null||t.startsWith(`__`))continue;let i=r.name;if(!i.startsWith(`__`)){if(n[i]!=null){console.warn(`Duplicate schema type name ${i} found; keeping the existing one found in the schema`);continue}n[i]=r}}for(let t in n)e[t]=n[t];for(let e of t)e.args=e.args.filter(e=>(e.type=c(e.type),e.type!==null));for(let t in e){let i=e[t];!t.startsWith(`__`)&&t in n&&i!=null&&r(i)}for(let t in e)!t.startsWith(`__`)&&!(t in n)&&delete e[t];function r(e){if(j(e)){i(e),a(e);return}else if(Ct(e)){i(e),`getInterfaces`in e&&a(e);return}else if(wt(e)){s(e);return}else if(Et(e)){o(e);return}else if(At(e))return;throw Error(`Unexpected schema type: ${e}`)}function i(e){let t=e.getFields();for(let[e,n]of Object.entries(t))n.args.map(e=>(e.type=c(e.type),e.type===null?null:e)).filter(Boolean),n.type=c(n.type),n.type===null&&delete t[e]}function a(e){if(`getInterfaces`in e){let t=e.getInterfaces();t.push(...t.splice(0).map(e=>c(e)).filter(Boolean))}}function o(e){let t=e.getFields();for(let[e,n]of Object.entries(t))n.type=c(n.type),n.type===null&&delete t[e]}function s(e){let t=e.getTypes();t.push(...t.splice(0).map(e=>c(e)).filter(Boolean))}function c(t){if(Dt(t)){let e=c(t.ofType);return e==null?null:new Nt(e)}else if(M(t)){let e=c(t.ofType);return e==null?null:new N(e)}else if(Lt(t)){let n=e[t.name];if(n&&t!==n)return n}return t}}function ks(e,t){let n=e.getTypeMap();for(let e in n){let r=n[e];if(!Rt(r).name.startsWith(`__`)&&j(r)){let n=r.getFields();for(let r in n){let i=n[r];t(i,e,r)}}}}function As(e,t){let n=e.getTypeMap();for(let e in n){let r=n[e];if(!Rt(r).name.startsWith(`__`)){if(j(r)){let e=r.getFields();for(let n in e){let r=e[n];for(let e of r.args)e.defaultValue=t(e.type,e.defaultValue)}}else if(Et(r)){let e=r.getFields();for(let n in e){let r=e[n];r.defaultValue=t(r.type,r.defaultValue)}}}}}function js(e,t=!1,n=!1,r=!1){let i,a=!0,o=e.every(e=>{if(Array.isArray(e)){if(i===void 0)return i=e.length,!0;if(i===e.length)return!0}else a=!1;return!1});if(r&&o)return Array(i).fill(null).map((i,a)=>js(e.map(e=>e[a]),t,n,r));if(a)return e.flat(1);let s,c;t&&(c=e.find(e=>Ms(e)),s??={},c&&Object.setPrototypeOf(s,Object.create(Object.getPrototypeOf(c))));for(let i of e)if(Ms(i)){if(c){let e=Object.getPrototypeOf(s),t=Object.getPrototypeOf(i);if(t)for(let n of Object.getOwnPropertyNames(t)){let r=Object.getOwnPropertyDescriptor(t,n);ka(r)&&Object.defineProperty(e,n,r)}}for(let e in i)s??={},e in s?s[e]=js([s[e],i[e]],t,n,r):s[e]=i[e]}else s=Array.isArray(i)&&Array.isArray(s)?js([s,i],t,n,r):i;return s}function Ms(e){return e&&typeof e==`object`&&!Array.isArray(e)}var Ns=class extends Map{get[Symbol.toStringTag](){return`AccumulatorMap`}add(e,t){let n=this.get(e);n===void 0?this.set(e,[t]):n.push(t)}};const Ps=new vn({name:`defer`,description:"Directs the executor to defer this fragment when the `if` argument is true or undefined.",locations:[T.FRAGMENT_SPREAD,T.INLINE_FRAGMENT],args:{if:{type:new N(fn),description:`Deferred when true or undefined.`,defaultValue:!0},label:{type:dn,description:`Unique name`}}}),Fs=new vn({name:`stream`,description:"Directs the executor to stream plural fields when the `if` argument is true or undefined.",locations:[T.FIELD],args:{if:{type:new N(fn),description:`Stream when true or undefined.`,defaultValue:!0},label:{type:dn,description:`Unique name`},initialCount:{defaultValue:0,type:ln,description:`Number of items to return immediately`}}});function Is(e,t,n,r,i,a,o,s){for(let c of i.selections)switch(c.kind){case E.FIELD:if(!Rs(n,c))continue;a.add(Bs(c),c);break;case E.INLINE_FRAGMENT:{if(!Rs(n,c)||!zs(e,c,r))continue;let i=Vs(n,c);if(i){let a=new Ns;Is(e,t,n,r,c.selectionSet,a,o,s),o.push({label:i.label,fields:a})}else Is(e,t,n,r,c.selectionSet,a,o,s);break}case E.FRAGMENT_SPREAD:{let i=c.name.value;if(!Rs(n,c))continue;let l=Vs(n,c);if(s.has(i)&&!l)continue;let u=t[i];if(!u||!zs(e,u,r))continue;if(l||s.add(i),l){let i=new Ns;Is(e,t,n,r,u.selectionSet,i,o,s),o.push({label:l.label,fields:i})}else Is(e,t,n,r,u.selectionSet,a,o,s);break}}}function Ls(e,t,n,r,i){let a=new Ns,o=[];return Is(e,t,n,r,i,a,o,new Set),{fields:a,patches:o}}function Rs(e,t){return!(ki(bn,t,e)?.if===!0||ki(yn,t,e)?.if===!1)}function zs(e,t,n){let r=t.typeCondition;if(!r)return!0;let i=pr(e,r);return i===n?!0:Mt(i)?e.getPossibleTypes(i).includes(n):!1}function Bs(e){return e.alias?e.alias.value:e.name.value}function Vs(e,t){let n=ki(Ps,t,e);if(n&&n.if!==!1)return{label:typeof n.label==`string`?n.label:void 0}}const Hs=so(function(e,t,n,r,i){let a=new Ns,o=new Set,s=[],c={fields:a,patches:s};for(let c of i)c.selectionSet&&Is(e,t,n,r,c.selectionSet,a,s,o);return c});function Us(e){return e?.[Symbol.asyncIterator]!=null}function Ws(e){return e&&typeof e==`object`&&`kind`in e&&e.kind===E.DOCUMENT}function Gs(e,t,n){return{prev:e,key:t,typename:n}}function Ks(e){let t=[],n=e;for(;n;)t.push(n.key),n=n.prev;return t.reverse()}function qs(e){return e.map(e=>typeof e==`number`?`[`+e.toString()+`]`:`.`+e).join(``)}function Js(e,t,n){if(typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t))for(n=0;n<t.length;n++)e[n]=Js(e[n],t[n]);else for(n in t){if(n===`__proto__`||n===`constructor`||n===`prototype`)break;e[n]=Js(e[n],t[n])}return e}return t}function Ys(e,t,n){t.split&&(t=t.split(`.`));for(var r=0,i=t.length,a=e,o,s;r<i&&(s=``+t[r++],!(s===`__proto__`||s===`constructor`||s===`prototype`));)a=a[s]=r===i?Js(a[s],n):typeof(o=a[s])==typeof t?o:t[r]*0!=0||~(``+t[r]).indexOf(`.`)?{}:[]}function Xs({incrementalResult:e,executionResult:t}){let n=[`data`,...e.path??[]];if(e.items)for(let r of e.items)Ys(t,n,r),n[n.length-1]++;e.data&&Ys(t,n,e.data),e.errors&&(t.errors=t.errors||[],t.errors.push(...e.errors)),e.extensions&&Ys(t,`extensions`,e.extensions),e.incremental&&e.incremental.forEach(e=>{Xs({incrementalResult:e,executionResult:t})})}const Zs={red:`\x1B[31m`,yellow:`\x1B[33m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,reset:`\x1B[0m`},Qs=Zs.yellow+`WARN`+Zs.reset,$s=Zs.cyan+`INFO`+Zs.reset,ec=Zs.red+`ERR`+Zs.reset,tc=Zs.magenta+`DEBUG`+Zs.reset,nc={debug:0,info:1,warn:2,error:3,silent:4},rc=()=>{},ic=e=>(...t)=>console.log(e,...t),ac=console.debug?(...e)=>console.debug(tc,...e):ic(tc),oc=console.info?(...e)=>console.info($s,...e):ic($s),sc=console.warn?(...e)=>console.warn(Qs,...e):ic(Qs),cc=console.error?(...e)=>console.error(ec,...e):ic(ec),lc=(e={}.DEBUG===`1`?`debug`:`info`)=>{let t=nc[e];return{debug:t>nc.debug?rc:ac,info:t>nc.info?rc:oc,warn:t>nc.warn?rc:sc,error:t>nc.error?rc:cc}};var uc=`<!doctype html><html lang=en><head><meta charset=utf-8><title>__TITLE__</title><link rel=icon href=https://raw.githubusercontent.com/graphql-hive/graphql-yoga/refs/heads/main/website/src/app/favicon.ico><link crossorigin rel=stylesheet href=https://unpkg.com/@graphql-yoga/graphiql@4.4.1/dist/graphiql.css></head><body id=body class=no-focus-outline><noscript>You need to enable JavaScript to run this app.</noscript><div id=root></div><script>self.MonacoEnvironment=function(o){return{globalAPI:!1,getWorkerUrl:function(r,n){var t=o[n];if(t.includes("://")){var e=String(window.location),i=e.substr(0,e.length-window.location.hash.length-window.location.search.length-window.location.pathname.length);if(t.substring(0,i.length)!==i){var a=new Blob(["/*"+n+'*/importScripts("'+t+'");'],{type:"application/javascript"});return URL.createObjectURL(a)}}return t}}}({editorWorkerService:"https://unpkg.com/@graphql-yoga/graphiql@4.4.1/dist/monacoeditorwork/editor.worker.bundle.js",json:"https://unpkg.com/@graphql-yoga/graphiql@4.4.1/dist/monacoeditorwork/json.worker.bundle.js",graphql:"https://unpkg.com/@graphql-yoga/graphiql@4.4.1/dist/monacoeditorwork/graphql.worker..bundle.js"})<\/script><script type=module>import{renderYogaGraphiQL}from"https://unpkg.com/@graphql-yoga/graphiql@4.4.1/dist/yoga-graphiql.es.js";renderYogaGraphiQL(root,__OPTS__)<\/script></body></html>`;function dc({headers:e,method:t}){return t===`GET`&&!!e?.get(`accept`)?.includes(`text/html`)}const fc=e=>uc.replace(`__TITLE__`,e?.title||`Yoga GraphiQL`).replace(`__OPTS__`,JSON.stringify(e??{}));function pc(e){let t=e.logger??console,n;n=typeof e?.options==`function`?e?.options:typeof e?.options==`object`?()=>e?.options:e?.options===!1?()=>!1:()=>({});let r=e?.render??fc,i,a=({URLPattern:t})=>(i||=new t({pathname:e.graphqlEndpoint}),i);return{onRequest({request:i,serverContext:o,fetchAPI:s,endResponse:c,url:l}){if(dc(i)&&(i.url.endsWith(e.graphqlEndpoint)||i.url.endsWith(`${e.graphqlEndpoint}/`)||l.pathname===e.graphqlEndpoint||l.pathname===`${e.graphqlEndpoint}/`||a(s).test(l)))return t.debug(`Rendering GraphiQL`),F(()=>n(i,o),e=>{if(e)return F(()=>r({...e===!0?{}:e}),e=>{c(new s.Response(e,{headers:{"Content-Type":`text/html`},status:200}))})})}}}const mc=e=>{if(e==null)return{};if(Un(e))return{onPluginInit({setSchema:t}){t(e)}};if(`then`in e){let t;return{onRequestParse(){return{onRequestParseDone(){if(!t)return F(()=>e,e=>{t=e})}}},onEnveloped({setSchema:e}){if(!t)throw Error(`You provide a promise of a schema but it hasn't been resolved yet. Make sure you use this plugin with GraphQL Yoga.`);e(t)}}}let t=new WeakMap;return{onRequestParse({request:n,serverContext:r}){return{onRequestParseDone(){return F(()=>e({...r,request:n}),e=>{t.set(n,e)})}}},onEnveloped({setSchema:e,context:n}){if(n?.request==null)throw Error(`Request object is not available in the context. Make sure you use this plugin with GraphQL Yoga.`);let r=t.get(n.request);if(r==null)throw Error(`No schema found for this request. Make sure you use this plugin with GraphQL Yoga.`);e(r)}}};function hc(e,t={}){let{requireResolversForArgs:n,requireResolversForNonScalar:r,requireResolversForAllFields:i}=t;if(i&&(n||r))throw TypeError(`requireResolversForAllFields takes precedence over the more specific assertions. Please configure either requireResolversForAllFields or requireResolversForArgs / requireResolversForNonScalar, but not a combination of them.`);ks(e,(e,t,a)=>{i&&gc(`requireResolversForAllFields`,i,e,t,a),n&&e.args.length>0&&gc(`requireResolversForArgs`,n,e,t,a),r!==`ignore`&&!St(Rt(e.type))&&gc(`requireResolversForNonScalar`,r,e,t,a)})}function gc(e,t,n,r,i){if(!n.resolve){let n=`Resolver missing for "${r}.${i}".
77
+ To disable this validator, use:
78
+ resolverValidationOptions: {
79
+ ${e}: 'ignore'
80
+ }`;if(t===`error`)throw Error(n);t===`warn`&&console.warn(n);return}if(typeof n.resolve!=`function`)throw Error(`Resolver "${r}.${i}" must be a function`)}function _c(e,t){ds(e,{[L.ABSTRACT_TYPE]:e=>{if(!e.resolveType){let n=`Type "${e.name}" is missing a "__resolveType" resolver. Pass 'ignore' into "resolverValidationOptions.requireResolversForResolveType" to disable this error.`;if(t===`error`)throw Error(n);t===`warn`&&console.warn(n)}}})}function vc(e,t){let n={},r=e.getTypeMap();for(let e in r){let i=r[e];if(`getInterfaces`in i){n[e]={};for(let r of i.getInterfaces())if(t[r.name])for(let i in t[r.name])(i===`__isTypeOf`||!i.startsWith(`__`))&&(n[e][i]=t[r.name][i]);let r=t[e];n[e]={...n[e],...r}}else{let r=t[e];r!=null&&(n[e]=r)}}return n}function yc({schema:e,resolvers:t,defaultFieldResolver:n,resolverValidationOptions:r={},inheritResolversFromInterfaces:i=!1,updateResolversInPlace:a=!1}){let{requireResolversToMatchSchema:o=`error`,requireResolversForResolveType:s}=r,c=i?vc(e,t):t;for(let t in c){let n=c[t];if(typeof n!=`object`)throw Error(`"${t}" defined in resolvers, but has invalid value "${n}". The resolver's value must be of type object.`);let r=e.getType(t);if(r==null){let e=`"${t}" defined in resolvers, but not in schema`;if(o&&o!==`error`){o===`warn`&&console.warn(e);continue}throw Error(e)}else if(hn(r))for(let e in n)e.startsWith(`__`)?r[e.substring(2)]=n[e]:r[e]=n[e];else if(Tt(r)){let e=r.getValues();for(let t in n)if(!t.startsWith(`__`)&&!e.some(e=>e.name===t)&&o&&o!==`ignore`){let e=`${r.name}.${t} was defined in resolvers, but not present within ${r.name}`;if(o===`error`)throw Error(e);console.warn(e)}}else if(wt(r)){for(let e in n)if(!e.startsWith(`__`)&&o&&o!==`ignore`){let t=`${r.name}.${e} was defined in resolvers, but ${r.name} is not an object or interface type`;if(o===`error`)throw Error(t);console.warn(t)}}else if(j(r)||Ct(r)){for(let e in n)if(!e.startsWith(`__`))if(r.getFields()[e]==null){if(o&&o!==`ignore`){let n=`${t}.${e} defined in resolvers, but not in schema`;if(o===`error`)throw Error(n);console.error(n)}}else{let r=n[e];if(typeof r!=`function`&&typeof r!=`object`)throw Error(`Resolver ${t}.${e} must be object or function`)}}}return e=a?bc(e,c,n):xc(e,c,n),s&&s!==`ignore`&&_c(e,s),e}function bc(e,t,n){let r=e.getTypeMap();for(let n in t){let i=e.getType(n),a=t[n];if(St(i))for(let e in a)e.startsWith(`__`)?i[e.substring(2)]=a[e]:e===`astNode`&&i.astNode!=null?i.astNode={...i.astNode,description:a?.astNode?.description??i.astNode.description,directives:(i.astNode.directives??[]).concat(a?.astNode?.directives??[])}:e===`extensionASTNodes`&&i.extensionASTNodes!=null?i.extensionASTNodes=i.extensionASTNodes.concat(a?.extensionASTNodes??[]):e===`extensions`&&i.extensions!=null&&a.extensions!=null?i.extensions=Object.assign(Object.create(null),i.extensions,a.extensions):i[e]=a[e];else if(Tt(i)){let e=i.toConfig(),t=e.values;for(let n in a)n.startsWith(`__`)?e[n.substring(2)]=a[n]:n===`astNode`&&e.astNode!=null?e.astNode={...e.astNode,description:a?.astNode?.description??e.astNode.description,directives:(e.astNode.directives??[]).concat(a?.astNode?.directives??[])}:n===`extensionASTNodes`&&e.extensionASTNodes!=null?e.extensionASTNodes=e.extensionASTNodes.concat(a?.extensionASTNodes??[]):n===`extensions`&&i.extensions!=null&&a.extensions!=null?i.extensions=Object.assign(Object.create(null),i.extensions,a.extensions):t[n]&&(t[n].value=a[n]);r[n]=new $t(e)}else if(wt(i))for(let e in a)e.startsWith(`__`)&&(i[e.substring(2)]=a[e]);else if(j(i)||Ct(i))for(let e in a){if(e.startsWith(`__`)){i[e.substring(2)]=a[e];continue}let t=i.getFields()[e];if(t!=null){let n=a[e];typeof n==`function`?t.resolve=n.bind(a):Sc(t,n)}}}return As(e,ls),Ds(e),As(e,us),n!=null&&ks(e,e=>{e.resolve||=n}),e}function xc(e,t,n){return e=ds(e,{[L.SCALAR_TYPE]:e=>{let n=e.toConfig(),r=t[e.name];if(!hn(e)&&r!=null){for(let t in r)t.startsWith(`__`)?n[t.substring(2)]=r[t]:t===`astNode`&&n.astNode!=null?n.astNode={...n.astNode,description:r?.astNode?.description??n.astNode.description,directives:(n.astNode.directives??[]).concat(r?.astNode?.directives??[])}:t===`extensionASTNodes`&&n.extensionASTNodes!=null?n.extensionASTNodes=n.extensionASTNodes.concat(r?.extensionASTNodes??[]):t===`extensions`&&n.extensions!=null&&r.extensions!=null?n.extensions=Object.assign(Object.create(null),e.extensions,r.extensions):n[t]=r[t];return new Vt(n)}},[L.ENUM_TYPE]:e=>{let n=t[e.name],r=e.toConfig(),i=r.values;if(n!=null){for(let t in n)t.startsWith(`__`)?r[t.substring(2)]=n[t]:t===`astNode`&&r.astNode!=null?r.astNode={...r.astNode,description:n?.astNode?.description??r.astNode.description,directives:(r.astNode.directives??[]).concat(n?.astNode?.directives??[])}:t===`extensionASTNodes`&&r.extensionASTNodes!=null?r.extensionASTNodes=r.extensionASTNodes.concat(n?.extensionASTNodes??[]):t===`extensions`&&r.extensions!=null&&n.extensions!=null?r.extensions=Object.assign(Object.create(null),e.extensions,n.extensions):i[t]&&(i[t].value=n[t]);return new $t(r)}},[L.UNION_TYPE]:e=>{let n=t[e.name];if(n!=null){let t=e.toConfig();return n.__resolveType&&(t.resolveType=n.__resolveType),new Zt(t)}},[L.OBJECT_TYPE]:e=>{let n=t[e.name];if(n!=null){let t=e.toConfig();return n.__isTypeOf&&(t.isTypeOf=n.__isTypeOf),new Ht(t)}},[L.INTERFACE_TYPE]:e=>{let n=t[e.name];if(n!=null){let t=e.toConfig();return n.__resolveType&&(t.resolveType=n.__resolveType),new Xt(t)}},[L.COMPOSITE_FIELD]:(e,n,r)=>{let i=t[r];if(i!=null){let t=i[n];if(t!=null){let n={...e};return typeof t==`function`?n.resolve=t.bind(i):Sc(n,t),n}}}}),n!=null&&(e=ds(e,{[L.OBJECT_FIELD]:e=>({...e,resolve:e.resolve==null?n:e.resolve})})),e}function Sc(e,t){for(let n in t)e[n]=t[n]}function Cc(e,t){if(!e||Array.isArray(e)&&e.length===0)return{};if(!Array.isArray(e))return e;if(e.length===1)return e[0]||{};let n=[];for(let t of e)Array.isArray(t)&&(t=Cc(t)),typeof t==`object`&&t&&n.push(t);let r=js(n,!0);if(t?.exclusions)for(let e of t.exclusions){let[t,n]=e.split(`.`);[`__proto__`,`constructor`,`prototype`].includes(t)||[`__proto__`,`constructor`,`prototype`].includes(n)||(!n||n===`*`?delete r[t]:r[t]&&delete r[t][n])}return r}function wc(e,t,n){let r=Tc([...t,...e].filter(ka),n);return n&&n.sort&&r.sort(Oa),r}function Tc(e,t){return e.reduce((e,n)=>{let r=e.findIndex(e=>e.name.value===n.name.value);return r===-1?e.concat([n]):(t?.reverseArguments||(e[r]=n),e)},[])}function Ec(e,t,n){return!!(t?.[e.name.value]?.repeatable??n?.has(e.name.value))}function Dc(e,t){return t.some(({value:t})=>t===e.value)}function Oc(e,t){let n=[];for(let r of[...t,...e]){let e=n.findIndex(e=>e.name.value===r.name.value);if(e===-1)n.push(r);else{let t=n[e];if(t.value.kind===`ListValue`){let e=t.value.values,n=r.value.values;t.value={...t.value,values:Pc(e,n,(e,t)=>{let n=e.value;return!n||!t.some(e=>e.value===n)})}}else t.value=r.value}}return n}const kc=(e,t)=>{if(e.kind===t.kind)switch(e.kind){case E.LIST:return e.values.length===t.values.length&&e.values.every(e=>t.values.find(t=>kc(e,t)));case E.VARIABLE:case E.NULL:return!0;case E.OBJECT:return e.fields.length===t.fields.length&&e.fields.every(e=>t.fields.find(t=>e.name.value===t.name.value&&kc(e.value,t.value)));default:return e.value===t.value}return!1},Ac=(e,t)=>e.name.value===t.name.value&&e.value.kind===t.value.kind&&kc(e.value,t.value),jc=(e,t)=>!!(e.name.value===t.name.value&&(e.arguments===t.arguments||e.arguments?.length===t.arguments?.length&&e.arguments?.every(e=>t.arguments?.find(t=>Ac(e,t)))));function Mc(e=[],t=[],n,r){let i=n&&n.reverseDirectives,a=i?e:t,o=i?t:e,s=[];for(let e of[...a,...o])if(Ec(e,r,n?.repeatableLinkImports))s.find(t=>jc(e,t))||s.push(e);else{let t=s.findIndex(t=>t.name.value===e.name.value);if(t===-1)s.push(e);else{let n=Oc(e.arguments??[],s[t].arguments??[]);s[t]={...s[t],arguments:n.length===0?void 0:n}}}return s}function Nc(e,t){return t?{...e,arguments:Pc(t.arguments||[],e.arguments||[],(e,t)=>!Dc(e.name,t.map(e=>e.name))),locations:[...t.locations,...e.locations.filter(e=>!Dc(e,t.locations))]}:e}function Pc(e,t,n){return e.concat(t.filter(t=>n(t,e)))}function Fc(e,t,n,r){if(n?.consistentEnumMerge){let n=[];e&&n.push(...e),e=t,t=n}let i=new Map;if(e)for(let t of e)i.set(t.name.value,t);if(t)for(let e of t){let t=e.name.value;if(i.has(t)){let n=i.get(t);n.description=e.description||n.description,n.directives=Mc(e.directives,n.directives,r)}else i.set(t,e)}let a=[...i.values()];return n&&n.sort&&a.sort(Oa),a}function Ic(e,t,n,r){return t?{name:e.name,description:e.description||t.description,kind:n?.convertExtensions||e.kind===`EnumTypeDefinition`||t.kind===`EnumTypeDefinition`?`EnumTypeDefinition`:`EnumTypeExtension`,loc:e.loc,directives:Mc(e.directives,t.directives,n,r),values:Fc(e.values,t.values,n)}:n?.convertExtensions?{...e,kind:E.ENUM_TYPE_DEFINITION}:e}function Lc(e){return typeof e==`string`}function Rc(e){return e instanceof Be}function zc(e){let t=e;for(;t.kind===E.LIST_TYPE||t.kind===`NonNullType`;)t=t.type;return t}function Bc(e){return e.kind!==E.NAMED_TYPE}function Vc(e){return e.kind===E.LIST_TYPE}function Hc(e){return e.kind===E.NON_NULL_TYPE}function Uc(e){return Vc(e)?`[${Uc(e.type)}]`:Hc(e)?`${Uc(e.type)}!`:e.name.value}var Wc;(function(e){e[e.A_SMALLER_THAN_B=-1]=`A_SMALLER_THAN_B`,e[e.A_EQUALS_B=0]=`A_EQUALS_B`,e[e.A_GREATER_THAN_B=1]=`A_GREATER_THAN_B`})(Wc||={});function Gc(e,t){return e==null&&t==null?Wc.A_EQUALS_B:e==null?Wc.A_SMALLER_THAN_B:t==null?Wc.A_GREATER_THAN_B:e<t?Wc.A_SMALLER_THAN_B:e>t?Wc.A_GREATER_THAN_B:Wc.A_EQUALS_B}function Kc(e,t){let n=e.findIndex(e=>e.name.value===t.name.value);return[n>-1?e[n]:null,n]}function qc(e,t,n,r,i){let a=[];if(n!=null&&a.push(...n),t!=null)for(let n of t){let[t,o]=Kc(a,n);if(t&&!r?.ignoreFieldConflicts){let s=r?.onFieldTypeConflict&&r.onFieldTypeConflict(t,n,e,r?.throwOnConflict)||Jc(e,t,n,r?.throwOnConflict);s.arguments=wc(n.arguments||[],t.arguments||[],r),s.directives=Mc(n.directives,t.directives,r,i),s.description=n.description||t.description,a[o]=s}else a.push(n)}if(r&&r.sort&&a.sort(Oa),r&&r.exclusions){let t=r.exclusions;return a.filter(n=>!t.includes(`${e.name.value}.${n.name.value}`))}return a}function Jc(e,t,n,r=!1){let i=Uc(t.type),a=Uc(n.type);if(i!==a){let o=zc(t.type),s=zc(n.type);if(o.name.value!==s.name.value)throw Error(`Field "${n.name.value}" already defined with a different type. Declared as "${o.name.value}", but you tried to override with "${s.name.value}"`);if(!Yc(t.type,n.type,!r))throw Error(`Field '${e.name.value}.${t.name.value}' changed type from '${i}' to '${a}'`)}return Hc(n.type)&&!Hc(t.type)&&(t.type=n.type),t}function Yc(e,t,n=!1){return!Bc(e)&&!Bc(t)?e.toString()===t.toString():Hc(t)?Yc(Hc(e)?e.type:e,t.type):Hc(e)?Yc(t,e,n):Vc(e)?Vc(t)&&Yc(e.type,t.type)||Hc(t)&&Yc(e,t.type):!1}function Xc(e,t,n,r){if(t)try{return{name:e.name,description:e.description||t.description,kind:n?.convertExtensions||e.kind===`InputObjectTypeDefinition`||t.kind===`InputObjectTypeDefinition`?`InputObjectTypeDefinition`:`InputObjectTypeExtension`,loc:e.loc,fields:qc(e,e.fields,t.fields,n),directives:Mc(e.directives,t.directives,n,r)}}catch(t){throw Error(`Unable to merge GraphQL input type "${e.name.value}": ${t.message}`)}return n?.convertExtensions?{...e,kind:E.INPUT_OBJECT_TYPE_DEFINITION}:e}function Zc(e,t){return!!e.find(e=>e.name.value===t.name.value)}function Qc(e=[],t=[],n={}){let r=[...t,...e.filter(e=>!Zc(t,e))];return n&&n.sort&&r.sort(Oa),r}function $c(e,t,n,r){if(t)try{return{name:e.name,description:e.description||t.description,kind:n?.convertExtensions||e.kind===`InterfaceTypeDefinition`||t.kind===`InterfaceTypeDefinition`?`InterfaceTypeDefinition`:`InterfaceTypeExtension`,loc:e.loc,fields:qc(e,e.fields,t.fields,n,r),directives:Mc(e.directives,t.directives,n,r),interfaces:e.interfaces?Qc(e.interfaces,t.interfaces,n):void 0}}catch(t){throw Error(`Unable to merge GraphQL interface "${e.name.value}": ${t.message}`)}return n?.convertExtensions?{...e,kind:E.INTERFACE_TYPE_DEFINITION}:e}function el(e,t,n,r){return t?{name:e.name,description:e.description||t.description,kind:n?.convertExtensions||e.kind===`ScalarTypeDefinition`||t.kind===`ScalarTypeDefinition`?`ScalarTypeDefinition`:`ScalarTypeExtension`,loc:e.loc,directives:Mc(e.directives,t.directives,n,r)}:n?.convertExtensions?{...e,kind:E.SCALAR_TYPE_DEFINITION}:e}const tl={query:`Query`,mutation:`Mutation`,subscription:`Subscription`};function nl(e=[],t=[]){let n=[];for(let r in tl){let i=e.find(e=>e.operation===r)||t.find(e=>e.operation===r);i&&n.push(i)}return n}function rl(e,t,n,r){return t?{kind:e.kind===E.SCHEMA_DEFINITION||t.kind===E.SCHEMA_DEFINITION?E.SCHEMA_DEFINITION:E.SCHEMA_EXTENSION,description:e.description||t.description,directives:Mc(e.directives,t.directives,n,r),operationTypes:nl(e.operationTypes,t.operationTypes)}:n?.convertExtensions?{...e,kind:E.SCHEMA_DEFINITION}:e}function il(e,t,n,r){if(t)try{return{name:e.name,description:e.description||t.description,kind:n?.convertExtensions||e.kind===`ObjectTypeDefinition`||t.kind===`ObjectTypeDefinition`?`ObjectTypeDefinition`:`ObjectTypeExtension`,loc:e.loc,fields:qc(e,e.fields,t.fields,n,r),directives:Mc(e.directives,t.directives,n,r),interfaces:Qc(e.interfaces,t.interfaces,n)}}catch(t){throw Error(`Unable to merge GraphQL type "${e.name.value}": ${t.message}`)}return n?.convertExtensions?{...e,kind:E.OBJECT_TYPE_DEFINITION}:e}function al(e,t,n,r){return t?{name:e.name,description:e.description||t.description,directives:Mc(e.directives,t.directives,n,r),kind:n?.convertExtensions||e.kind===`UnionTypeDefinition`||t.kind===`UnionTypeDefinition`?E.UNION_TYPE_DEFINITION:E.UNION_TYPE_EXTENSION,loc:e.loc,types:Qc(e.types,t.types,n)}:n?.convertExtensions?{...e,kind:E.UNION_TYPE_DEFINITION}:e}const ol=`SCHEMA_DEF_SYMBOL`;function sl(e){return`name`in e}function cl(e,t,n={}){let r=n;for(let i of e)if(sl(i)){let e=i.name?.value;if(t?.commentDescriptions&&zo(i),e==null)continue;if(t?.exclusions?.includes(e+`.*`)||t?.exclusions?.includes(e))delete r[e];else switch(i.kind){case E.OBJECT_TYPE_DEFINITION:case E.OBJECT_TYPE_EXTENSION:r[e]=il(i,r[e],t,n);break;case E.ENUM_TYPE_DEFINITION:case E.ENUM_TYPE_EXTENSION:r[e]=Ic(i,r[e],t,n);break;case E.UNION_TYPE_DEFINITION:case E.UNION_TYPE_EXTENSION:r[e]=al(i,r[e],t,n);break;case E.SCALAR_TYPE_DEFINITION:case E.SCALAR_TYPE_EXTENSION:r[e]=el(i,r[e],t,n);break;case E.INPUT_OBJECT_TYPE_DEFINITION:case E.INPUT_OBJECT_TYPE_EXTENSION:r[e]=Xc(i,r[e],t,n);break;case E.INTERFACE_TYPE_DEFINITION:case E.INTERFACE_TYPE_EXTENSION:r[e]=$c(i,r[e],t,n);break;case E.DIRECTIVE_DEFINITION:r[e]&&e in{}&&(ll(r[e])||(r[e]=void 0)),r[e]=Nc(i,r[e]);break}}else(i.kind===E.SCHEMA_DEFINITION||i.kind===E.SCHEMA_EXTENSION)&&(r[ol]=rl(i,r[ol],t));return r}function ll(e){return typeof e==`object`&&!!e&&`kind`in e&&typeof e.kind==`string`}function ul(e){return e.as??e.url.name}function dl(e){let t=ul(e);return t&&`@${t}`}function fl(e,t){if(e.url.name&&t===`@${e.url.name}`)return dl(e).substring(1);let n=e.imports.find(e=>e.name===t),r=n?.as??n?.name??pl(ul(e),t);return r.startsWith(`@`)?r.substring(1):r}function pl(e,t){return e?.length?t.startsWith(`@`)?`@${e}__${t.substring(1)}`:`${e}__${t}`:t}function ml(e){let t=[];for(let n of e.definitions)if(n.kind===E.SCHEMA_EXTENSION||n.kind===E.SCHEMA_DEFINITION){let e=(n.directives?.filter(e=>e.name.value===`link`))?.map(e=>hl(e.arguments??[])).filter(e=>e!==void 0)??[];t=t.concat(e);let r=(n.directives?.filter(({name:e})=>e.value===`core`))?.map(e=>gl(e.arguments??[])).filter(e=>e!==void 0);r&&(t=t.concat(...r))}return t}function hl(e){let t,n=[],r;for(let i of e)switch(i.name.value){case`url`:i.value.kind===E.STRING&&(t=yl(i.value.value));break;case`import`:n=_l(i.value);break;case`as`:i.value.kind===E.STRING&&(r=i.value.value??void 0);break;default:}if(t!==void 0)return{url:t,as:r,imports:n}}function gl(e){let t=e.find(({name:e,value:t})=>e.value===`feature`&&t.kind===E.STRING);if(t)return{url:yl(t.value.value),imports:[]}}function _l(e){return e.kind===E.LIST?e.values.map(e=>{let t;if(e.kind===E.STRING)t={name:e.value};else if(e.kind===E.OBJECT){let n=``,r;for(let t of e.fields)t.name.value===`name`?t.value.kind===E.STRING&&(n=t.value.value):t.name.value===`as`&&t.value.kind===E.STRING&&(r=t.value.value);t={name:n,as:r}}return t}).filter(e=>e!==void 0):[]}const vl=/v(\d{1,3})\.(\d{1,4})/i;function yl(e){let t=new URL(e),n=t.pathname.split(`/`).filter(Boolean),r=n[n.length-1];if(r){if(vl.test(r)){let e=n[n.length-2];return{identity:t.origin+(e?`/${n.slice(0,n.length-1).join(`/`)}`:``),name:e??null,version:r}}return{identity:`${t.origin}/${n.join(`/`)}`,name:r,version:null}}return{identity:t.origin,name:null,version:null}}function bl(e,t){Ro();let n={kind:E.DOCUMENT,definitions:Sl(e,{useSchemaDefinition:!0,forceSchemaDefinition:!1,throwOnConflict:!1,commentDescriptions:!1,...t})},r;return r=t?.commentDescriptions?Xo(n):n,Ro(),r}function xl(e,t,n=[],r=[],i=new Set,a=new Set){let o=e=>{a.add(e)};if(e&&!i.has(e))if(i.add(e),typeof e==`function`)xl(e(),t,n,r,i,a);else if(Array.isArray(e))for(let o of e)xl(o,t,n,r,i,a);else if(Un(e))xl(bo(e,t).definitions,t,n,r,i,a);else if(Lc(e)||Rc(e))xl(He(e,t).definitions,t,n,r,i,a);else if(typeof e==`object`&&_r(e)){let t=ml({definitions:[e],kind:E.DOCUMENT}),i=t.find(e=>e.url.identity===`https://specs.apollo.dev/federation`);i&&(o(fl(i,`@composeDirective`)),o(fl(i,`@key`)));let a=t.find(e=>e.url.identity===`https://specs.apollo.dev/link`);a&&o(fl(a,`@link`)),e.kind===E.DIRECTIVE_DEFINITION?n.push(e):r.push(e)}else if(Ws(e))xl(e.definitions,t,n,r,i,a);else throw Error(`typeDefs must contain only strings, documents, schemas, or functions, got ${typeof e}`);return{allDirectives:n,allNodes:r,repeatableLinkImports:a}}function Sl(e,t){Ro();let{allDirectives:n,allNodes:r,repeatableLinkImports:i}=xl(e,t),a=cl(n,t);t.repeatableLinkImports=i;let o=cl(r,t,a);if(t?.useSchemaDefinition){let e=o.SCHEMA_DEF_SYMBOL||{kind:E.SCHEMA_DEFINITION,operationTypes:[]},t=e.operationTypes;for(let e in tl)if(!t.find(t=>t.operation===e)){let n=o[tl[e]];n!=null&&n.name!=null&&t.push({kind:E.OPERATION_TYPE_DEFINITION,type:{kind:E.NAMED_TYPE,name:n.name},operation:e})}e?.operationTypes?.length!=null&&e.operationTypes.length>0&&(o[ol]=e)}t?.forceSchemaDefinition&&!o.SCHEMA_DEF_SYMBOL?.operationTypes?.length&&(o[ol]={kind:E.SCHEMA_DEFINITION,operationTypes:[{kind:E.OPERATION_TYPE_DEFINITION,operation:`query`,type:{kind:E.NAMED_TYPE,name:{kind:E.NAME,value:`Query`}}}]});let s=Object.values(o);if(t?.sort){let e=typeof t.sort==`function`?t.sort:Gc;s.sort((t,n)=>e(t.name?.value,n.name?.value))}return s}function Cl(e,t){if(!(!e||!t||t===e.extensions)){if(!e.extensions){e.extensions=t;return}e.extensions=js([e.extensions,t],!1,!0)}}function wl(e,t){Cl(e,t.schemaExtensions);for(let[n,r]of Object.entries(t.types||{})){let t=e.getType(n);if(t){if(Cl(t,r.extensions),r.type===`object`||r.type===`interface`)for(let[e,n]of Object.entries(r.fields)){let r=t.getFields()[e];if(r){Cl(r,n.extensions);for(let[e,t]of Object.entries(n.arguments))Cl(r.args.find(t=>t.name===e),t)}}else if(r.type===`input`)for(let[e,n]of Object.entries(r.fields)){let r=t.getFields()[e];Cl(r,n.extensions)}else if(r.type===`enum`)for(let[e,n]of Object.entries(r.values))Cl(t.getValue(e),n)}}return e}function Tl({typeDefs:e,resolvers:t={},resolverValidationOptions:n={},inheritResolversFromInterfaces:r=!1,updateResolversInPlace:i=!1,schemaExtensions:a,defaultFieldResolver:o,...s}){if(typeof n!=`object`)throw Error("Expected `resolverValidationOptions` to be an object");if(!e)throw Error(`Must provide typeDefs`);let c;if(c=Un(e)?e:s?.commentDescriptions?wa(bl(e,{...s,commentDescriptions:!0}),s):Ca(bl(e,s),s),c=yc({schema:c,resolvers:Cc(t),resolverValidationOptions:n,inheritResolversFromInterfaces:r,updateResolversInPlace:i,defaultFieldResolver:o}),Object.keys(n).length>0&&hc(c,n),a)for(let e of Ta(a))wl(c,e);return c}function El(e){return Tl(e)}function Dl(e,t){let n={...t,...e};for(let r of Object.keys(n))r in e&&r in t&&(n[r]=(n,i)=>e[r](n,()=>t[r](n,i)));return n}const Ol=e=>({fn(t,n){return t?(...r)=>{let i;return t(e,()=>{i=n(...r)}),i}:n},asyncFn(t,n){return t?(...r)=>{let i;return F(()=>t(e,()=>(i=n(...r),Va(i)?i.then(()=>void 0):void 0)),()=>i)}:n}}),kl=new WeakMap;function Al(e,t){let n=kl.get(e);return!n&&t&&(n=t(e),kl.set(e,n)),n}function jl(e){return e.length===1?e[0]:{schema:e[0],document:e[1],rootValue:e[2],contextValue:e[3],variableValues:e[4],operationName:e[5],fieldResolver:e[6],subscribeFieldResolver:e[7]}}const Ml=e=>((...t)=>e(jl(t)));function Nl(e){return e.length===1?e[0]:{schema:e[0],document:e[1],rootValue:e[2],contextValue:e[3],variableValues:e[4],operationName:e[5],fieldResolver:e[6],typeResolver:e[7]}}const Pl=e=>((...t)=>e(Nl(t)));function Fl(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}function Il(e,t){if(Fl(e.result))return{onNext:t};t({args:e.args,result:e.result,setResult:e.setResult})}function Ll(e,t){let n;function r(){return n||=e[Symbol.asyncIterator](),n}let i=!1;return{[Symbol.asyncIterator](){return this},next(){return r().next().then(e=>(e.done&&i===!1&&(i=!0,t()),e))},return(){let e=r().return?.();return i===!1&&(i=!0,t()),e||Ha({done:!0,value:void 0})},throw(e){let t=r().throw?.();if(t)return t;throw e},[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)](){return Ha()}}}function Rl(e,t){let n;function r(){return n||=e[Symbol.asyncIterator](),n}return{[Symbol.asyncIterator](){return this},next(){return r().next().catch(e=>(t(e),{done:!0,value:void 0}))},return(){return r().return?.()||Ha({done:!0,value:void 0})},throw(e){let t=r().throw?.();if(t)return t;throw e},[Symbol.asyncDispose||Symbol.for(`Symbol.asyncDispose`)](){return Ha()}}}function zl(e){throw Error(`No \`${e}\` function found! Register it using "useEngine" plugin.`)}function Bl({plugins:e}){let t=null,n=!1,r=()=>zl(`parse`),i=()=>zl(`validate`),a=()=>zl(`execute`),o=()=>zl(`subscribe`),s,c=(r,i=-1)=>{if(t!==r&&(t=r,n))for(let[n,r]of e.entries())n!==i&&r.onSchemaChange&&r.onSchemaChange({schema:t,replaceSchema:e=>{c(e,n)}})},l=[];for(let t=0;t<e.length;t++){let n=e[t],r=[];n.onPluginInit?.({plugins:e,addPlugin:e=>{r.push(e)},setSchema:e=>c(e,t),registerContextErrorHandler:e=>l.push(e)}),r.length&&e.splice(t+1,0,...r)}let u={init:[],parse:[],validate:[],subscribe:[],execute:[],context:[]};for(let{onContextBuilding:t,onExecute:n,onParse:r,onSubscribe:i,onValidate:a,onEnveloped:o,instrumentation:c}of e)o&&u.init.push(o),t&&u.context.push(t),n&&u.execute.push(n),r&&u.parse.push(r),i&&u.subscribe.push(i),a&&u.validate.push(a),c&&(s=s?Dl(s,c):c);let d=e=>{for(let[t,n]of u.init.entries())n({context:e,extendContext:t=>{e&&Object.assign(e,t)},setSchema:e=>c(e,t)})},f=u.parse.length?e=>(t,n)=>{let i=null,a=r,o=e,s=[];for(let e of u.parse){let r=e({context:o,extendContext:e=>{Object.assign(o,e)},params:{source:t,options:n},parseFn:a,setParseFn:e=>{a=e},setParsedDocument:e=>{i=e}});r&&s.push(r)}if(i===null)try{i=a(t,n)}catch(e){i=e}for(let e of s)e({context:o,extendContext:e=>{Object.assign(o,e)},replaceParseResult:e=>{i=e},result:i});if(i===null)throw Error(`Failed to parse document.`);if(i instanceof Error)throw i;return kl.set(i,t.toString()),i}:()=>r,p=u.validate.length?e=>(t,n,r,a,o)=>{let s=r?[...r]:void 0,c=i,l=null,d=e,f=[];for(let e of u.validate){let r=e({context:d,extendContext:e=>{Object.assign(d,e)},params:{schema:t,documentAST:n,rules:s,typeInfo:a,options:o},validateFn:c,addValidationRule:e=>{s||=[],s.push(e)},setValidationFn:e=>{c=e},setResult:e=>{l=e}});r&&f.push(r)}if(l||=c(t,n,s,a,o),!l)return;let p=l.length===0;for(let e of f)e({valid:p,result:l,context:d,extendContext:e=>{Object.assign(d,e)},setResult:e=>{l=e}});return l}:()=>i,m=u.context.length?e=>t=>{let n=[],r=e;t&&Object.assign(r,t);let i=!1;return F(()=>Wa(u.context,(e,t)=>e({context:r,extendContext:e=>{Object.assign(r,e)},breakContextBuilding:()=>{i=!0,t()}}),n),()=>i?r:F(()=>Wa(n,e=>e({context:r,extendContext(e){Object.assign(r,e)}})),()=>r),e=>{let t=e;for(let e of l)e({context:r,error:t,setError:e=>{t=e}});throw t})}:e=>t=>(t&&Object.assign(e,t),e),h=u.subscribe.length?Ml(e=>{let t=o,n=[],r=e.contextValue||{},i;return F(()=>Wa(u.subscribe,(n,a)=>n({subscribeFn:t,setSubscribeFn:e=>{t=e},context:r,extendContext:e=>{Object.assign(r,e)},args:e,setResultAndStopExecution:e=>{i=e,a()}}),n),()=>{let r=[],a=[];for(let{onSubscribeResult:e,onSubscribeError:t}of n)e&&r.push(e),t&&a.push(t);return F(()=>i||t(e),t=>{let n=[],i=[];for(let a of r){let r=a({args:e,result:t,setResult:e=>{t=e}});r&&(r.onNext&&n.push(r.onNext),r.onEnd&&i.push(r.onEnd))}return n.length&&Fl(t)&&(t=qa(t,t=>F(()=>Wa(n,n=>n({args:e,result:t,setResult:e=>t=e})),()=>t))),i.length&&Fl(t)&&(t=Ll(t,()=>{for(let e of i)e()})),a.length&&Fl(t)&&(t=Rl(t,e=>{let t=e;for(let e of a)e({error:t,setError:e=>{t=e}});throw t})),t})})}):Ml(o),g=u.execute.length?Pl(e=>{let t=a,n,r=[],i=[],o=e.contextValue||{};return F(()=>Wa(u.execute,(r,i)=>r({executeFn:t,setExecuteFn:e=>{t=e},setResultAndStopExecution:e=>{n=e,i()},context:o,extendContext:e=>{if(typeof e==`object`)Object.assign(o,e);else throw Error(`Invalid context extension provided! Expected "object", got: "${JSON.stringify(e)}" (${typeof e})`)},args:e}),r),()=>F(()=>n||t({...e,contextValue:o}),t=>F(()=>Wa(r,n=>n.onExecuteDone?.({args:e,result:t,setResult:e=>{t=e}}),i),()=>{let n=[],r=[];for(let{onNext:e,onEnd:t}of i)e&&n.push(e),t&&r.push(t);return n.length&&Fl(t)&&(t=qa(t,t=>F(()=>Wa(n,n=>n({args:e,result:t,setResult:e=>{t=e}})),()=>t))),r.length&&Fl(t)&&(t=Ll(t,()=>{for(let e of r)e()})),t})))}):Pl(a);if(n=!0,t)for(let[n,r]of e.entries())r.onSchemaChange?.({schema:t,replaceSchema:e=>c(e,n)});return{getCurrentSchema(){return t},init:d,parse:f,validate:p,execute:g,subscribe:h,contextFactory:m,instrumentation:s}}function Vl(e){return e!=null}function Hl(e){let t=e.plugins.filter(Vl),n=Bl({plugins:t}),r=n.instrumentation,i=(e={})=>{let t=Ol({context:e}),i=n;return t.fn(r?.init,n.init)(e),{parse:t.fn(r?.parse,i.parse(e)),validate:t.fn(r?.validate,i.validate(e)),contextFactory:t.fn(r?.context,i.contextFactory(e)),execute:t.asyncFn(r?.execute,i.execute),subscribe:t.asyncFn(r?.subscribe,i.subscribe),schema:i.getCurrentSchema()}};return i._plugins=t,i}function Ul(e){return e instanceof Error&&e.name===`GraphQLError`}function Wl(e){return Ul(e)?e.originalError==null?!0:Wl(e.originalError):!1}function Gl(e,t,n){let r=Error(e);if(r.name=`GraphQLError`,n){let e=t instanceof Error?{message:t.message,stack:t.stack}:{message:String(t)};Object.defineProperty(r,"extensions",{get(){return e}})}return Object.defineProperty(r,"toJSON",{value(){return{message:r.message,extensions:r.extensions}}}),r}const Kl=(e=>(t,n)=>Wl(t)?t:Gl(n,t,e))(!1),ql=(e,t)=>({result:n,setResult:r})=>{n.errors!=null&&r({...n,errors:n.errors.map(n=>e(n,t))})};function Jl(e){let t=e?.maskError??Kl,n=e?.errorMessage||`Unexpected error.`,r=ql(t,n);return{onPluginInit(e){e.registerContextErrorHandler(({error:e,setError:r})=>{r(t(e,n))})},onExecute(){return{onExecuteDone(e){return Il(e,r)}}},onSubscribe(){return{onSubscribeResult(e){return Il(e,r)},onSubscribeError({error:e,setError:r}){r(t(e,n))}}}}}const Yl=e=>({result:t,args:n})=>{t.errors?.length&&e({errors:t.errors,context:n,phase:`execution`})},Xl=e=>{let t=Yl(e);return{onParse(){return function({result:t,context:n}){t instanceof Error&&e({errors:[t],context:n,phase:`parse`})}},onValidate(){return function({valid:t,result:n,context:r}){t===!1&&n.length>0&&e({errors:n,context:r,phase:`validate`})}},onPluginInit(t){t.registerContextErrorHandler(({error:n})=>{Ul(n)?e({errors:[n],context:t,phase:`context`}):e({errors:[Error(n)],context:t,phase:`context`})})},onExecute(){return{onExecuteDone(e){return Il(e,t)}}},onSubscribe(){return{onSubscribeResult(e){return Il(e,t)}}}}},Zl=e=>({onContextBuilding({context:t,extendContext:n}){return F(()=>e(t),e=>n(e))}}),Ql=e=>({onExecute:({setExecuteFn:t})=>{e.execute&&t(e.execute)},onParse:({setParseFn:t})=>{e.parse&&t(e.parse)},onValidate:({setValidationFn:t,addValidationRule:n})=>{e.validate&&t(e.validate),e.specifiedRules?.map(n)},onSubscribe:({setSubscribeFn:t})=>{e.subscribe&&t(e.subscribe)}});var $l=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};const eu={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function tu(e){return e?.[eu.dispose]!=null}function nu(e){return e?.[eu.asyncDispose]!=null}const ru=globalThis.SuppressedError||$l;var iu=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return nu(e)?this.callbacks.push(()=>e[eu.asyncDispose]()):tu(e)&&this.callbacks.push(()=>e[eu.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[eu.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return F(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new ru(e,this._error):e,this._iterateCallbacks()))}[eu.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};globalThis.SuppressedError,eu.dispose,globalThis.DisposableStack;const au=globalThis.AsyncDisposableStack||iu;globalThis.SuppressedError;function ou(e){if(e instanceof Error)return e;if(typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`){let t;`cause`in e&&(t={cause:e.cause});let n=Error(e.message,t);return`stack`in e&&typeof e.stack==`string`&&(n.stack=e.stack),`name`in e&&typeof e.name==`string`&&(n.name=e.name),n}return Error(String(e))}function su(e){let t=e[Symbol.asyncIterator](),n,r,i=!1;async function a(){if(i)return{value:void 0,done:!0};try{if(!n){if(r)return await r,await a();let e;r=new Promise(t=>{e=t});let o=await t.next();return o.done?(i=!0,await a()):(n=o.value[Symbol.asyncIterator](),r=void 0,e(),await a())}let e=n,o=await n.next();return o.done?(n===e&&(n=void 0),await a()):o}catch(e){throw i=!0,e}}return{next:a,async return(){return i=!0,await Promise.all([n?.return?.(),t.return?.()]),{value:void 0,done:!0}},async throw(e){throw i=!0,await Promise.all([n?.throw?.(e),t.throw?.(e)]),e},[Symbol.asyncIterator](){return this},async[eu.asyncDispose](){i=!0,await Promise.all([n?.[eu.asyncDispose]?.(),t?.[eu.asyncDispose]?.()])}}}function cu(e,t){if(!e)throw Error(t??`Unexpected invariant triggered.`)}function lu(e,t,n){t?.throwIfAborted();let r=Object.create(null),i=[];for(let t in e){let n=F(()=>e[t],e=>{r[t]=e});Va(n)&&i.push(n)}if(!i.length)return r;let a=i.length===1?i[0]:Promise.all(i);return n?Promise.race([n,a]).then(()=>r):a.then(()=>r)}function uu(e,t,n,r){let i=[],a=r?.maxErrors;try{let r=du(e,t,n,e=>{if(a!=null&&i.length>=a)throw P(`Too many errors processing variables, error limit reached. Execution aborted.`);i.push(e)});if(i.length===0)return{coerced:r}}catch(e){i.push(e)}return{errors:i}}function du(e,t,n,r){let i={};for(let a of t){let t=a.variable.name.value,o=pr(e,a.type);if(!Ot(o)){r(P(`Variable "$${t}" expected value of type "${ft(a.type)}" which cannot be used as an input type.`,{nodes:a.type}));continue}if(!no(n,t)){a.defaultValue?i[t]=Ei(a.defaultValue,o):M(o)&&r(P(`Variable "$${t}" of required type "${Aa(o)}" was not provided.`,{nodes:a}));continue}let s=n[t];if(s===null&&M(o)){r(P(`Variable "$${t}" of non-null type "${Aa(o)}" must not be null.`,{nodes:a}));continue}i[t]=Ci(s,o,(e,n,i)=>{let o=`Variable "$${t}" got invalid value `+Aa(n);e.length>0&&(o+=` at "${t}${qs(e)}"`),r(P(o+`; `+i.message,{nodes:a,originalError:i}))})}return i}const fu=ao((e,t,n)=>Hs(e.schema,e.fragments,e.variableValues,t,n));function pu(e){let t=_u(e);return`schema`in t?mu(t):{errors:t.map(e=>(Object.defineProperty(e,"extensions",{value:{...e.extensions,http:{...e.extensions?.http||{},status:400}}}),e))}}function mu(e){return e.signal?.throwIfAborted(),F(()=>yu(e),t=>{let n=hu(t,e.errors);return e.subsequentPayloads.size>0?{initialResult:{...n,hasNext:!0},subsequentResults:$u(e)}:n},t=>(e.signal?.throwIfAborted(),t.errors?e.errors.push(...t.errors):e.errors.push(t),hu(null,e.errors)))}function hu(e,t){return t.length===0?{data:e}:{errors:t,data:e}}const gu=io(function(e){let t=Object.create(null);for(let n of e.definitions)n.kind===E.FRAGMENT_DEFINITION&&(t[n.name.value]=n);return t});function _u(e){let{schema:t,document:n,rootValue:r,contextValue:i,variableValues:a,operationName:o,fieldResolver:s,typeResolver:c,subscribeFieldResolver:l,signal:u}=e;u?.throwIfAborted(),Jn(t);let d=gu(n),f;for(let e of n.definitions)switch(e.kind){case E.OPERATION_DEFINITION:if(o==null){if(f!==void 0)return[P(`Must provide operation name if query contains multiple operations.`,{extensions:{code:`OPERATION_RESOLUTION_FAILURE`}})];f=e}else e.name?.value===o&&(f=e);break;default:}if(f==null)return o==null?[P(`Must provide an operation.`,{extensions:{code:`OPERATION_RESOLUTION_FAILURE`}})]:[P(`Unknown operation named "${o}".`,{extensions:{code:`OPERATION_RESOLUTION_FAILURE`}})];let p=uu(t,f.variableDefinitions??[],a??{},{maxErrors:50});if(p.errors)return p.errors;u?.throwIfAborted();let m,h;if(u){let e=new Set,t=Ua();h=t.promise;let n=()=>{t.reject(u.reason),u.removeEventListener(`abort`,n)};u.addEventListener(`abort`,n,{once:!0}),h.catch(()=>{for(let t of e)t();e.clear()}),m=t=>{e.add(t)}}return{schema:t,fragments:d,rootValue:r,contextValue:i,operation:f,variableValues:p.coerced,fieldResolver:s??Lu,typeResolver:c??Iu,subscribeFieldResolver:l??Lu,subsequentPayloads:new Set,errors:[],signal:u,onSignalAbort:m,signalPromise:h}}function vu(e,t){return{...e,rootValue:t,subsequentPayloads:new Set,errors:[]}}function yu(e){let{operation:t,schema:n,fragments:r,variableValues:i,rootValue:a}=e,o=vo(n,t.operation,[t]);o??P(`Schema is not configured to execute ${t.operation} operation.`,{nodes:t});let{fields:s,patches:c}=Ls(n,r,i,o,t.selectionSet),l;l=t.operation===`mutation`?bu(e,o,a,void 0,s):xu(e,o,a,void 0,s);for(let t of c){let{label:n,fields:r}=t;qu(e,o,a,r,n,void 0)}return l}function bu(e,t,n,r,i){return to(i,(i,[a,o])=>{let s=Gs(r,a,t.name);return e.signal?.throwIfAborted(),F(()=>Su(e,t,n,o,s),e=>(e===void 0||(i[a]=e),i))},Object.create(null))}function xu(e,t,n,r,i,a){let o=Object.create(null),s=!1;try{for(let[c,l]of i){e.signal?.throwIfAborted();let i=Su(e,t,n,l,Gs(r,c,t.name),a);i!==void 0&&(o[c]=i,Va(i)&&(s=!0))}}catch(t){if(t!==e.signal?.reason&&s)return F(()=>lu(o,e.signal),()=>{throw t},()=>{throw t});throw t}return s?lu(o,e.signal,e.signalPromise):o}function Su(e,t,n,r,i,a){let o=a?.errors??e.errors,s=rd(e.schema,t,r[0]);if(!s)return;let c=s.type,l=s.resolve??e.fieldResolver,u=Cu(e,s,r,t,i);try{e.signal?.throwIfAborted();let t=ro(s,r[0],e.variableValues),d=e.contextValue,f=l(n,t,d,u),p;return p=Va(f)?f.then(t=>Tu(e,c,r,u,i,t,a)):Tu(e,c,r,u,i,f,a),Va(p)?p.then(void 0,t=>{if(t instanceof AggregateError){let n;for(let s of t.errors)s=ou(s),n=wu(ma(s,r,Ks(i)),c,o),Zu(e,i,a);return n}t=ou(t);let n=wu(ma(t,r,Ks(i)),c,o);return Zu(e,i,a),n}):p}catch(t){if(t instanceof AggregateError){let n;for(let s of t.errors)s=ou(s),n=wu(ma(s,r,Ks(i)),c,o),Zu(e,i,a);return n}let n=wu(ma(ou(t),r,Ks(i)),c,o);return Zu(e,i,a),n}}function Cu(e,t,n,r,i){return{fieldName:t.name,fieldNodes:n,returnType:t.type,parentType:r,path:i,schema:e.schema,fragments:e.fragments,rootValue:e.rootValue,operation:e.operation,variableValues:e.variableValues,signal:e.signal}}function wu(e,t,n){if(M(t)||e.extensions?.CRITICAL_ERROR)throw e;return n.push(e),null}function Tu(e,t,n,r,i,a,o){if(a instanceof Error)throw a;if(M(t)){let s=Tu(e,t.ofType,n,r,i,a,o);if(s===null)throw Error(`Cannot return null for non-nullable field ${r.parentType.name}.${r.fieldName}.`);return s}if(a==null)return null;if(Dt(t))return Ou(e,t,n,r,i,a,o);if(At(t))return Au(t,a);if(Mt(t))return ju(e,t,n,r,i,a,o);if(j(t))return Nu(e,t,n,r,i,a,o);console.assert(!1,`Cannot complete value of unexpected output type: `+Aa(t))}function Eu(e,t,n){if(typeof n.key==`number`)return;let r=ki(Fs,t[0],e.variableValues);if(r&&r.if!==!1)return cu(typeof r.initialCount==`number`,`initialCount must be a number`),cu(r.initialCount>=0,`initialCount must be a positive integer`),{initialCount:r.initialCount,label:typeof r.label==`string`?r.label:void 0}}async function Du(e,t,n,r,i,a,o){e.signal?.throwIfAborted(),a.return&&e.onSignalAbort?.(()=>{a.return?.()});let s=o?.errors??e.errors,c=Eu(e,n,i),l=!1,u=[],d=0;for(;;){if(c&&typeof c.initialCount==`number`&&d>=c.initialCount){Xu(d,a,e,n,r,t,i,c.label,o);break}let f=Gs(i,d,void 0),p;try{if(p=await a.next(),p.done)break}catch(e){let r=ma(ou(e),n,Ks(f));u.push(wu(r,t,s));break}ku(p.value,u,s,e,t,n,r,f,o)&&(l=!0),d+=1}return l?Promise.all(u):u}function Ou(e,t,n,r,i,a,o){let s=t.ofType,c=o?.errors??e.errors;if(Us(a))return Du(e,s,n,r,i,a[Symbol.asyncIterator](),o);if(!$a(a))throw P(`Expected Iterable, but did not find one for field "${r.parentType.name}.${r.fieldName}".`);let l=Eu(e,n,i),u=!1,d=o,f=[],p=0;for(let t of a){let a=Gs(i,p,void 0);if(l&&typeof l.initialCount==`number`&&p>=l.initialCount){d=Ju(i,a,t,e,n,r,s,l.label,d),p++;continue}ku(t,f,c,e,s,n,r,a,o)&&(u=!0),p++}return u?Promise.all(f):f}function ku(e,t,n,r,i,a,o,s,c){try{let l;if(l=Va(e)?e.then(e=>Tu(r,i,a,o,s,e,c)):Tu(r,i,a,o,s,e,c),Va(l))return t.push(l.then(void 0,e=>{e=ou(e);let t=wu(ma(e,a,Ks(s)),i,n);return Zu(r,s,c),t})),!0;t.push(l)}catch(e){let o=wu(ma(ou(e),a,Ks(s)),i,n);Zu(r,s,c),t.push(o)}return!1}function Au(e,t){let n;try{n=e.serialize(t)}catch(e){throw e instanceof S?Error(e.message):e}if(n==null)throw Error(`Expected \`${Aa(e)}.serialize(${Aa(t)})\` to return non-nullable value, returned: ${Aa(n)}`);return n}function ju(e,t,n,r,i,a,o){let s=t.resolveType??e.typeResolver,c=e.contextValue,l=s(a,c,r,t);return Va(l)?l.then(s=>Nu(e,Mu(s,e,t,n,r,a),n,r,i,a,o)):Nu(e,Mu(l,e,t,n,r,a),n,r,i,a,o)}function Mu(e,t,n,r,i,a){if(e==null)throw P(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}". Either the "${n.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,{nodes:r});if(j(e)){if(f.major>=16)throw P(`Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.`);e=e.name}if(typeof e!=`string`)throw P(`Abstract type "${n.name}" must resolve to an Object type at runtime for field "${i.parentType.name}.${i.fieldName}" with value ${Aa(a)}, received "${Aa(e)}".`);let o=t.schema.getType(e);if(o==null)throw P(`Abstract type "${n.name}" was resolved to a type "${e}" that does not exist inside the schema.`,{nodes:r});if(!j(o))throw P(`Abstract type "${n.name}" was resolved to a non-object type "${e}".`,{nodes:r});if(!t.schema.isSubType(n,o))throw P(`Runtime Object type "${o.name}" is not a possible type for "${n.name}".`,{nodes:r});return o}function Nu(e,t,n,r,i,a,o){if(t.isTypeOf){let s=t.isTypeOf(a,e.contextValue,r);if(Va(s))return s.then(r=>{if(!r)throw Pu(t,a,n);return Fu(e,t,n,i,a,o)});if(!s)throw Pu(t,a,n)}return Fu(e,t,n,i,a,o)}function Pu(e,t,n){return P(`Expected value of type "${e.name}" but got: ${Aa(t)}.`,{nodes:n})}function Fu(e,t,n,r,i,a){let{fields:o,patches:s}=fu(e,t,n),c=xu(e,t,i,r,o,a);for(let n of s){let{label:o,fields:s}=n;qu(e,t,i,s,o,r,a)}return c}const Iu=function(e,t,n,r){if(eo(e)&&typeof e.__typename==`string`)return e.__typename;let i=n.schema.getPossibleTypes(r),a=[];for(let r=0;r<i.length;r++){let o=i[r];if(o.isTypeOf){let i=o.isTypeOf(e,t,n);if(Va(i))a[r]=i;else if(i)return o.name}}if(a.length)return Promise.all(a).then(e=>{for(let t=0;t<e.length;t++)if(e[t])return i[t].name})},Lu=function(e,t,n,r){if(eo(e)||typeof e==`function`){let i=e[r.fieldName];return typeof i==`function`?e[r.fieldName](t,n,r):i}};function Ru(e){let t=_u(e);if(!(`schema`in t)){for(let e of t){let t=e.extensions||={},n=t.http||={};n.status=400,e.extensions.code=`BAD_USER_INPUT`}return{errors:t}}let n=Wu(t);return Va(n)?n.then(e=>Hu(t,e)):Hu(t,n)}function zu(e){return e?.initialResult}function Bu(e){let t=e.subsequentResults,n=!1,r=!1;return{[Symbol.asyncIterator](){return this},next(){return r?Ha({value:void 0,done:r}):n?t.next():(n=!0,Ha({value:e.initialResult,done:r}))},return(){return r=!0,t.return()},throw(e){return r=!0,t.throw(e)},[eu.asyncDispose](){return r=!0,t?.[eu.asyncDispose]?.()}}}async function*Vu(e){`initialResult`in e?yield*Bu(e):yield e}function Hu(e,t){return Us(t)?su(qa(t,t=>F(()=>mu(vu(e,t)),Vu),t=>{throw t instanceof AggregateError?AggregateError(t.errors.map(t=>Uu(t,e.operation)),t.message):Uu(t,e.operation)})):t}function Uu(e,t){return P(e.message,{originalError:e,nodes:[t]})}function Wu(e){try{let t=Gu(e);return Va(t)?t.then(void 0,e=>({errors:[e]})):t}catch(e){return{errors:[e]}}}function Gu(e){let{schema:t,fragments:n,operation:r,variableValues:i,rootValue:a}=e,o=t.getSubscriptionType();if(o==null)throw P(`Schema is not configured to execute subscription operation.`,{nodes:r});let{fields:s}=Ls(t,n,i,o,r.selectionSet),[c,l]=[...s.entries()][0],u=l[0].name.value,d=rd(t,o,l[0]);if(!d)throw P(`The subscription field "${u}" is not defined.`,{nodes:l});let f=Gs(void 0,c,o.name),p=Cu(e,d,l,o,f);try{let t=ro(d,l[0],i),n=e.contextValue,r=(d.subscribe??e.subscribeFieldResolver)(a,t,n,p);return Va(r)?r.then(t=>Ku(t,e.signal,e.onSignalAbort)).then(void 0,e=>{throw ma(e,l,Ks(f))}):Ku(r,e.signal,e.onSignalAbort)}catch(e){throw ma(e,l,Ks(f))}}function Ku(e,t,n){if(t?.throwIfAborted(),e instanceof Error)throw e;if(!Us(e))throw P(`Subscription field must return Async Iterable. Received: ${Aa(e)}.`);return n?{[Symbol.asyncIterator](){let t=e[Symbol.asyncIterator]();return t.return&&n?.(()=>{t.return?.()}),t}}:e}function qu(e,t,n,r,i,a,o){let s=new ed({label:i,path:a,parentContext:o,exeContext:e}),c;try{c=xu(e,t,n,a,r,s),Va(c)&&(c=c.then(null,e=>(s.errors.push(e),null)))}catch(e){s.errors.push(e),c=null}s.addData(c)}function Ju(e,t,n,r,i,a,o,s,c){let l=new td({label:s,path:t,parentContext:c,exeContext:r}),u;try{try{u=Va(n)?n.then(e=>Tu(r,o,i,a,t,e,l)):Tu(r,o,i,a,t,n,l),Va(u)&&(u=u.then(void 0,e=>{e=ou(e);let n=wu(ma(e,i,Ks(t)),o,l.errors);return Zu(r,t,l),n}))}catch(e){u=wu(ma(ou(e),i,Ks(t)),o,l.errors),Zu(r,t,l)}}catch(t){return l.errors.push(t),Zu(r,e,l),l.addItems(null),l}let d;return d=Va(u)?u.then(e=>[e],t=>(l.errors.push(t),Zu(r,e,l),null)):[u],l.addItems(d),l}async function Yu(e,t,n,r,i,a,o){let s;try{let{value:t,done:n}=await e.next();if(n)return a.setIsCompletedIterator(),{done:n,value:void 0};s=t}catch(e){return{done:!0,value:wu(ma(ou(e),n,Ks(o)),i,a.errors)}}let c;try{return c=Tu(t,i,n,r,o,s,a),Va(c)&&(c=c.then(void 0,e=>{let r=wu(ma(e,n,Ks(o)),i,a.errors);return Zu(t,o,a),r})),{done:!1,value:c}}catch(e){let r=wu(ma(e,n,Ks(o)),i,a.errors);return Zu(t,o,a),{done:!1,value:r}}}async function Xu(e,t,n,r,i,a,o,s,c){let l=e,u=c??void 0;for(;;){let e=Gs(o,l,void 0),c=new td({label:s,path:e,parentContext:u,iterator:t,exeContext:n}),d;try{d=await Yu(t,n,r,i,a,c,e)}catch(e){c.errors.push(e),Zu(n,o,c),c.addItems(null),t?.return&&t.return().catch(()=>{});return}let{done:f,value:p}=d,m;if(m=Va(p)?p.then(e=>[e],e=>(c.errors.push(e),Zu(n,o,c),null)):[p],c.addItems(m),f)break;u=c,l++}}function Zu(e,t,n){let r=Ks(t);e.subsequentPayloads.forEach(t=>{if(t!==n){for(let e=0;e<r.length;e++)if(t.path[e]!==r[e])return;nd(t)&&t.iterator?.return&&t.iterator.return().catch(()=>{}),e.subsequentPayloads.delete(t)}})}function Qu(e){let t=[];for(let n of e.subsequentPayloads){let r={};if(n.isCompleted){if(e.subsequentPayloads.delete(n),nd(n)){let e=n.items;if(n.isCompletedIterator)continue;r.items=e}else r.data=n.data??null;r.path=n.path,n.label&&(r.label=n.label),n.errors.length>0&&(r.errors=n.errors),t.push(r)}}return t}function $u(e){let t=!1;async function n(){if(t)return{value:void 0,done:!0};let r=Array.from(e.subsequentPayloads).map(e=>e.promise);if(e.signalPromise?await Promise.race([e.signalPromise,...r]):await Promise.race(r),t)return{value:void 0,done:!0};let i=Qu(e),a=e.subsequentPayloads.size>0;return!i.length&&a?n():(a||(t=!0),{value:i.length?{incremental:i,hasNext:a}:{hasNext:a},done:!1})}function r(){let t=[];return e.subsequentPayloads.forEach(e=>{nd(e)&&e.iterator?.return&&t.push(e.iterator.return())}),Promise.all(t)}return{[Symbol.asyncIterator](){return this},next:n,async return(){return await r(),t=!0,{value:void 0,done:!0}},async throw(e){throw await r(),t=!0,e},async[eu.asyncDispose](){await r(),t=!0}}}var ed=class{type;errors;label;path;promise;data;parentContext;isCompleted;_exeContext;_resolve;constructor(e){this.type=`defer`,this.label=e.label,this.path=Ks(e.path),this.parentContext=e.parentContext,this.errors=[],this._exeContext=e.exeContext,this._exeContext.subsequentPayloads.add(this),this.isCompleted=!1,this.data=null,this.promise=new Promise(e=>{this._resolve=t=>{e(t)}}).then(e=>{this.data=e,this.isCompleted=!0})}addData(e){let t=this.parentContext?.promise;if(t){this._resolve?.(t.then(()=>e));return}this._resolve?.(e)}},td=class{type;errors;label;path;items;promise;parentContext;iterator;isCompletedIterator;isCompleted;_exeContext;_resolve;constructor(e){this.type=`stream`,this.items=null,this.label=e.label,this.path=Ks(e.path),this.parentContext=e.parentContext,this.iterator=e.iterator,this.errors=[],this._exeContext=e.exeContext,this._exeContext.subsequentPayloads.add(this),this.isCompleted=!1,this.items=null,this.promise=new Promise(e=>{this._resolve=t=>{e(t)}}).then(e=>{this.items=e,this.isCompleted=!0})}addItems(e){let t=this.parentContext?.promise;if(t){this._resolve?.(t.then(()=>e));return}this._resolve?.(e)}setIsCompletedIterator(){this.isCompletedIterator=!0}};function nd(e){return e.type===`stream`}function rd(e,t,n){let r=n.name.value;return r===Rn.name&&e.getQueryType()===t?Rn:r===zn.name&&e.getQueryType()===t?zn:r===Bn.name?Bn:t.getFields()[r]}function id(e){let t=_a(e.document,e.operationName);if(t==null)throw Error(`Must provide an operation.`);return t.operation===`subscription`?Ru(e):F(()=>pu(e),e=>zu(e)?Bu(e):e)}var ad=s(((e,t)=>{t.exports.fetch=globalThis.fetch,t.exports.Headers=globalThis.Headers,t.exports.Request=globalThis.Request,t.exports.Response=globalThis.Response,t.exports.FormData=globalThis.FormData,t.exports.ReadableStream=globalThis.ReadableStream,t.exports.WritableStream=globalThis.WritableStream,t.exports.TransformStream=globalThis.TransformStream,t.exports.CompressionStream=globalThis.CompressionStream,t.exports.DecompressionStream=globalThis.DecompressionStream,t.exports.TextDecoderStream=globalThis.TextDecoderStream,t.exports.TextEncoderStream=globalThis.TextEncoderStream,t.exports.Blob=globalThis.Blob,t.exports.File=globalThis.File,t.exports.crypto=globalThis.crypto,t.exports.btoa=globalThis.btoa,t.exports.TextEncoder=globalThis.TextEncoder,t.exports.TextDecoder=globalThis.TextDecoder,t.exports.URLPattern=globalThis.URLPattern,t.exports.URL=globalThis.URL,t.exports.URLSearchParams=globalThis.URLSearchParams,t.exports.createFetch=()=>globalThis}));function od(e){return typeof e==`object`&&!!e&&typeof e[Symbol.asyncIterator]==`function`}function sd(e){return e.socket?.localPort?e.socket?.localPort:(e.headers?.[`:authority`]||e.headers?.host)?.split(`:`)?.[1]||80}function cd(e){if(e.headers?.[`:authority`])return e.headers?.[`:authority`];if(e.headers?.host)return e.headers?.host;let t=sd(e);if(e.hostname)return e.hostname+`:`+t;let n=e.socket?.localAddress;return n&&!n?.includes(`::`)&&!n?.includes(`ffff`)?`${n}:${t}`:`localhost`}function ld(e){let t=cd(e);return`${e.protocol||(e.socket?.encrypted?`https`:`http`)}://${t}${e.originalUrl||e.url||`/graphql`}`}function ud(e){let t=e[Symbol.toStringTag];return!!(typeof e==`string`||t===`Uint8Array`||t===`Blob`||t===`FormData`||t===`URLSearchParams`||od(e))}function dd(e,t,n,r){let i=e.raw||e.req||e,a=ld(i);if(e.query){let n=new t.URL(a);for(let t in e.query)n.searchParams.set(t,e.query[t]);a=n.toString()}let o=e.headers;if(e.headers?.[`:method`]){o={};for(let t in e.headers)t.startsWith(`:`)||(o[t]=e.headers[t])}let s=r?Pd():new AbortController;if(n?.once){let e=()=>{s.signal.aborted||(Object.defineProperty(i,"aborted",{value:!0}),s.abort(n.errored??void 0))};n.once(`error`,e),n.once(`close`,e),n.once(`finish`,()=>{n.removeListener(`close`,e)})}if(e.method===`GET`||e.method===`HEAD`)return new t.Request(a,{method:e.method,headers:o,signal:s.signal});let c=e.body;if(c!=null&&Object.keys(c).length>0){if(ud(c))return new t.Request(a,{method:e.method||`GET`,headers:o,body:c,signal:s.signal});let n=new t.Request(a,{method:e.method||`GET`,headers:o,signal:s.signal});return n.headers.get(`content-type`)?.includes(`json`)||n.headers.set(`content-type`,`application/json; charset=utf-8`),new Proxy(n,{get:(e,t,n)=>{switch(t){case`json`:return()=>Ha(c);case`text`:return()=>Ha(JSON.stringify(c));default:return globalThis.Bun?Reflect.get(e,t):Reflect.get(e,t,n)}}})}return new t.Request(a,{method:e.method,headers:o,signal:s.signal,body:i,duplex:`half`})}function fd(e){return e.read!=null}function pd(e){return fd(e)}function md(e){return e!=null&&e.setHeader!=null&&e.end!=null&&e.once!=null&&e.write!=null}function hd(e){return e!=null&&e.getReader!=null}function gd(e){return e!=null&&e.request!=null&&e.respondWith!=null}function _d(e){e?.socket?.setTimeout?.(0),e?.socket?.setNoDelay?.(!0),e?.socket?.setKeepAlive?.(!0)}function vd(e){e.end(null,null,null)}function yd(e,t){let n=!1,r=()=>{n=!0};e.once(`error`,r),e.once(`close`,r),e.once(`finish`,()=>{e.removeListener(`close`,r),e.removeListener(`error`,r)});let i=t[Symbol.asyncIterator](),a=()=>i.next().then(({done:t,value:r})=>{if(!(n||t))return F(()=>bd(r,e),()=>n?vd(e):a())});return a()}function bd(e,t){if(!t.write(e))return new Promise(e=>t.once(`drain`,e))}function xd(e,t,n,r){if(t.closed||t.destroyed||t.writableEnded)return;if(!e){t.statusCode=404,vd(t);return}if(r&&e.headers?.headersInit&&!Array.isArray(e.headers.headersInit)&&!e.headers.headersInit.get&&!e.headers._map&&!e.headers._setCookies?.length)t.writeHead(e.status,e.statusText,e.headers.headersInit);else{if(t.setHeaders)t.setHeaders(e.headers);else{let n=!1;e.headers.forEach((r,i)=>{if(i===`set-cookie`){if(n)return;n=!0;let r=e.headers.getSetCookie?.();if(r){t.setHeader(`set-cookie`,r);return}}t.setHeader(i,r)})}t.writeHead(e.status,e.statusText)}if(e.bodyType===`String`)return F(()=>bd(e.bodyInit,t),()=>vd(t));let i=e._buffer;if(i)return F(()=>bd(i,t),()=>vd(t));let a=e.body;if(a==null){vd(t);return}if(a[Symbol.toStringTag]===`Uint8Array`)return F(()=>bd(a,t),()=>vd(t));if(_d(n),fd(a)){t.once(`close`,()=>{a.destroy()}),a.pipe(t,{end:!0});return}if(hd(a))return Sd(n,t,a);if(od(a))return yd(t,a)}function Sd(e,t,n){let r=n.getReader();e?.once?.(`error`,e=>{r.cancel(e)});function i(){return r.read().then(({done:e,value:n})=>e?vd(t):F(()=>bd(n,t),i))}return i()}function Cd(e){return typeof e==`object`&&!!e&&(`body`in e||`cache`in e||`credentials`in e||`headers`in e||`integrity`in e||`keepalive`in e||`method`in e||`mode`in e||`redirect`in e||`referrer`in e||`referrerPolicy`in e||`signal`in e||`window`in e)}function wd(...e){let[t,...n]=e.filter(e=>typeof e==`object`&&!!e);return n.forEach(e=>{let n=Object.getOwnPropertyNames(e).reduce((t,n)=>(Object.getOwnPropertyDescriptor(e,n)&&(t[n]=Object.getOwnPropertyDescriptor(e,n)),t),{});Object.getOwnPropertySymbols(e).forEach(t=>{let r=Object.getOwnPropertyDescriptor(e,t);r?.enumerable&&(n[t]=r)}),Object.defineProperties(t,n)}),t}function Td(e,t){return new t(e.stack||e.message||e.toString(),{status:e.status||500})}function Ed(e,t){return e==null?t==null?{}:{waitUntil:t}:wd(Object.create(e),{waitUntil:t},e)}function Dd(e,t){if(t?.aborted)throw t.reason;if(Va(e)&&t){let n=Ua();function r(){n.reject(t.reason)}return t.addEventListener(`abort`,r,{once:!0}),e.then(function(e){n.resolve(e)}).catch(function(e){n.reject(e)}).finally(()=>{t.removeEventListener(`abort`,r)}),n.promise}return e}const Od=[`SIGINT`,`exit`,`SIGTERM`],kd=new Set;let Ad=!1;function jd(){if(!Ad){Ad=!0;for(let e of Od)globalThis.process.once(e,function(){return Promise.allSettled([...kd].map(e=>!e.disposed&&e.disposeAsync()))})}}function Md(e){globalThis.process&&(jd(),kd.has(e)||(kd.add(e),e.defer(()=>{kd.delete(e)})))}var Nd=class extends EventTarget{aborted=!1;_onabort=null;_reason;constructor(){super();let e=globalThis.process?.getBuiltinModule?.(`node:events`);e?.kMaxEventTargetListeners&&(this[e.kMaxEventTargetListeners]=0)}throwIfAborted(){if(this._nativeCtrl?.signal?.throwIfAborted)return this._nativeCtrl.signal.throwIfAborted();if(this.aborted)throw this._reason}_nativeCtrl;ensureNativeCtrl(){if(!this._nativeCtrl){let e=this.aborted;this._nativeCtrl=new AbortController,e&&this._nativeCtrl.abort(this._reason)}return this._nativeCtrl}abort(e){if(this._nativeCtrl?.abort)return this._nativeCtrl?.abort(e);this._reason=e||new DOMException(`This operation was aborted`,`AbortError`),this.aborted=!0,this.dispatchEvent(new Event(`abort`))}get signal(){return this._nativeCtrl?.signal?this._nativeCtrl.signal:this}get reason(){return this._nativeCtrl?.signal?this._nativeCtrl.signal.reason:this._reason}get onabort(){return this._onabort,this._onabort}set onabort(e){if(this._nativeCtrl?.signal){this._nativeCtrl.signal.onabort=e;return}this._onabort&&this.removeEventListener(`abort`,this._onabort),this._onabort=e,e&&this.addEventListener(`abort`,e)}};function Pd(){return globalThis.Bun||globalThis.Deno?new AbortController:new Proxy(new Nd,{get(e,t,n){if(t.toString().includes(`kDependantSignals`)){let n=e.ensureNativeCtrl();return Reflect.get(n.signal,t,n.signal)}return Reflect.get(e,t,n)},set(e,t,n,r){if(t.toString().includes(`kDependantSignals`)){let r=e.ensureNativeCtrl();return Reflect.set(r.signal,t,n,r.signal)}return Reflect.set(e,t,n,r)},getPrototypeOf(){return AbortSignal.prototype}})}function Fd(e){return!!e.onData}function Id({req:e,res:t,fetchAPI:n,controller:r}){let i=e.getMethod(),a,o=[],s=[e=>{o.push(e)}],c=e=>{for(let t of s)t(e)},l=!1,u=[()=>{l=!0}],d=()=>{for(let e of u)e()};t.onData(function(e,t){c(Buffer.from(Buffer.from(e,0,e.byteLength))),t&&d()});let f;if(i!==`get`&&i!==`head`){a=`half`,r.signal.addEventListener(`abort`,()=>{d()},{once:!0});let e;f=()=>(e||=new n.ReadableStream({start(e){for(let t of o)e.enqueue(t);if(l){e.close();return}s.push(t=>{e.enqueue(t)}),u.push(()=>{if(r.signal.reason){e.error(r.signal.reason);return}e.desiredSize&&e.close()})}}),e)}let p=new n.Headers;e.forEach((e,t)=>{p.append(e,t)});let m=`http://localhost${e.getUrl()}`,h=e.getQuery();h&&(m+=`?${h}`);let g;function _(){return f?l?y():f():null}let v=new n.Request(m,{method:i,headers:p,get body(){return _()},signal:r.signal,duplex:a});function y(){return g||=o.length===1?o[0]:Buffer.concat(o),g}function b(){return l?Ha(y()):new Promise((e,t)=>{try{u.push(()=>{e(y())})}catch(e){t(e)}})}return Object.defineProperties(v,{body:{get(){return _()},configurable:!0,enumerable:!0},json:{value(){return b().then(e=>e.toString(`utf8`)).then(e=>JSON.parse(e))},configurable:!0,enumerable:!0},text:{value(){return b().then(e=>e.toString(`utf8`))},configurable:!0,enumerable:!0},arrayBuffer:{value(){return b()},configurable:!0,enumerable:!0}}),v}function Ld(e,t){return new t.WritableStream({write(t){e.cork(()=>{e.write(t)})},close(){e.cork(()=>{e.end()})}})}function Rd(e,t,n,r){if(!t){e.writeStatus(`404 Not Found`),e.end();return}let i=t._buffer,a=t.bodyType===`String`?t.bodyInit:void 0;if(!n.signal.aborted&&(e.cork(()=>{e.writeStatus(`${t.status} ${t.statusText}`);for(let[n,r]of t.headers)if(n!==`content-length`){if(n===`set-cookie`){let r=t.headers.getSetCookie?.();if(r){for(let t of r)e.writeHeader(n,t);continue}}e.writeHeader(n,r)}a?e.end(a):i?e.end(i):t.body||e.end()}),!(a||i||!t.body)))return n.signal.addEventListener(`abort`,()=>{t.body?.locked||t.body?.cancel(n.signal.reason)},{once:!0}),t.body.pipeTo(Ld(e,r),{signal:n.signal}).catch(e=>{if(!n.signal.aborted)throw e})}var zd=u(ad(),1);function Bd(e){try{return!!e?.request}catch{return!1}}const Vd={};function Hd(e,t){let n=t?.__useSingleWriteHead==null?!0:t.__useSingleWriteHead,r={...zd,...t?.fetchAPI},i=t?.__useCustomAbortCtrl==null?r.Request!==globalThis.Request:t.__useCustomAbortCtrl,a=typeof e==`function`?e:e.handle,o=[],s=[],c,l=new Set,u;function d(){return u||(u=new au,t?.disposeOnProcessTerminate&&Md(u),u.defer(()=>{if(l.size>0)return Promise.allSettled(l).then(()=>{l.clear()},()=>{l.clear()})})),u}function f(e){Va(e)&&(d(),l.add(e),e.then(()=>{l.delete(e)},t=>{console.error(`Unexpected error while waiting: ${t.message||t}`),l.delete(e)}))}if(t?.plugins!=null)for(let e of t.plugins){e.instrumentation&&(c=c?Dl(c,e.instrumentation):e.instrumentation),e.onRequest&&o.push(e.onRequest),e.onResponse&&s.push(e.onResponse);let t=e[eu.dispose];t&&d().defer(t);let n=e[eu.asyncDispose];n&&d().defer(n),e.onDispose&&d().defer(e.onDispose)}let p=o.length>0||s.length>0?function(e,t){let n=a,i;if(o.length===0)return u();let c=e.parsedUrl||new Proxy(Vd,{get(t,n,i){return c=new r.URL(e.url,`http://localhost`),Reflect.get(c,n,c)}});function l(n){return s.length===0?n:F(()=>Wa(s,i=>i({request:e,response:n,serverContext:t,setResponse(e){n=e},fetchAPI:r})),()=>n)}function u(){return i?l(i):F(()=>n(e,t),l)}return F(()=>Wa(o,(a,o)=>a({request:e,setRequest(t){e=t},serverContext:t,fetchAPI:r,url:c,requestHandler:n,setRequestHandler(e){n=e},endResponse(e){i=e,e&&o()}})),u)}:a;if(c?.request){let e=p;p=(t,n)=>Ol({request:t}).asyncFn(c.request,e)(t,n)}function m(e,...t){let n=t.length>1?wd(...t):t[0]||{};n.waitUntil||=f;let a=dd(e,r,void 0,i);return p(a,n)}function h(e,t,...n){let a=t.raw||t,o=n.length>1?wd(...n):n[0]||{};o.waitUntil||=f;let s=dd(e,r,a,i);return p(s,o)}function g(e,t,...i){let a={req:e,res:t,waitUntil:f};return Qa(Ha().then(()=>h(e,t,a,...i)).catch(e=>Td(e,r.Response)).then(r=>xd(r,t,e,n)).catch(e=>console.error(`Unexpected error while handling request: ${e.message||e}`)))}function _(e,t,...n){let a={res:e,req:t,waitUntil:f},o=n.filter(e=>e!=null).length>0?wd(a,...n):a,s=i?Pd():new AbortController,c=e.end.bind(e),l=!1;e.end=function(e){return l=!0,c(e)},e.onAborted.bind(e)(function(){s.abort()}),e.onAborted=function(e){s.signal.addEventListener(`abort`,e,{once:!0})};let u=Id({req:t,res:e,fetchAPI:r,controller:s});return F(()=>F(()=>p(u,o),e=>e,e=>Td(e,r.Response)),t=>{if(!s.signal.aborted&&!l)return F(()=>Rd(e,t,s,r),e=>e,e=>{console.error(`Unexpected error while handling request: ${e.message||e}`)})})}function v(e,...t){if(!e.respondWith||!e.request)throw TypeError(`Expected FetchEvent, got ${e}`);let n=t.filter(e=>e!=null),r=n.length>0?wd({},e,...n):Ed(e),i=p(e.request,r);e.respondWith(i)}function y(e,...t){let n=t.filter(e=>e!=null),r=n.length>1?wd({},...n):Ed(n[0],n[0]==null||n[0].waitUntil==null?f:void 0);return p(e,r)}let b=(e,...t)=>{if(typeof e==`string`||`href`in e){let[n,...i]=t;if(Cd(n)){let t=y(new r.Request(e,n),...i),a=n.signal;return a?Dd(t,a):t}return y(new r.Request(e),...t)}return Dd(y(e,...t),e.signal)},x=(e,...t)=>{let[n,...r]=t;if(pd(e)){if(!md(n))throw TypeError(`Expected ServerResponse, got ${n}`);return g(e,n,...r)}if(Fd(e))return _(e,n,...r);if(md(n))throw TypeError(`Got Node response without Node request`);return Bd(e)?gd(e)?v(e,...t):y(e.request,e,...t):b(e,...t)},S={handleRequest:y,fetch:b,handleNodeRequest:m,handleNodeRequestAndResponse:h,requestListener:g,handleEvent:v,handleUWS:_,handle:x,get disposableStack(){return d()},[eu.asyncDispose](){return u&&!u.disposed?u.disposeAsync():Ha()},dispose(){return u&&!u.disposed?u.disposeAsync():Ha()},waitUntil:f},C=new Proxy(x,{has:(t,n)=>n in S||n in x||e&&n in e,get:(t,n)=>{if(globalThis.Deno||n===Symbol.asyncDispose||n===Symbol.dispose){let e=Reflect.get(S,n,S);if(e)return e}let r=S[n];if(r)return r.bind?r.bind(S):r;let i=x[n];if(i)return i.bind?i.bind(x):i;if(e){let t=e[n];if(t)return t.bind?function(...t){let r=e[n](...t);return r===e?C:r}:t}},apply(e,t,n){return x(...n)}});return C}function Ud(e,t){let n=e.headers.get(`origin`);if(t===!1||n==null)return null;let r={};if(t.origin==null||t.origin.length===0||t.origin.includes(`*`)?(r[`Access-Control-Allow-Origin`]=n,r.Vary=`Origin`):typeof t.origin==`string`?r[`Access-Control-Allow-Origin`]=t.origin:Array.isArray(t.origin)&&(t.origin.length===1?r[`Access-Control-Allow-Origin`]=t.origin[0]:t.origin.includes(n)?(r[`Access-Control-Allow-Origin`]=n,r.Vary=`Origin`):r[`Access-Control-Allow-Origin`]=`null`),t.methods?.length)r[`Access-Control-Allow-Methods`]=t.methods.join(`, `);else{let t=e.headers.get(`access-control-request-method`);t&&(r[`Access-Control-Allow-Methods`]=t)}if(t.allowedHeaders?.length)r[`Access-Control-Allow-Headers`]=t.allowedHeaders.join(`, `);else{let t=e.headers.get(`access-control-request-headers`);t&&(r[`Access-Control-Allow-Headers`]=t,r.Vary?r.Vary+=`, Access-Control-Request-Headers`:r.Vary=`Access-Control-Request-Headers`)}return t.credentials==null?r[`Access-Control-Allow-Origin`]!==`*`&&(r[`Access-Control-Allow-Credentials`]=`true`):t.credentials===!0&&(r[`Access-Control-Allow-Credentials`]=`true`),t.exposedHeaders&&(r[`Access-Control-Expose-Headers`]=t.exposedHeaders.join(`, `)),t.maxAge&&(r[`Access-Control-Max-Age`]=t.maxAge.toString()),r}function Wd(e,t,n){return F(()=>t(e,n),t=>Ud(e,t))}function Gd(e){let t=()=>({});if(e!=null)if(typeof e==`function`)t=e;else if(typeof e==`object`){let n={...e};t=()=>n}else e===!1&&(t=()=>!1);return{onRequest({request:e,fetchAPI:t,endResponse:n}){e.method.toUpperCase()===`OPTIONS`&&n(new t.Response(null,{status:204,headers:{"Content-Length":`0`}}))},onResponse({request:e,serverContext:n,response:r}){return F(()=>Wd(e,t,n),e=>{if(e!=null)for(let t in e)r.headers.set(t,e[t])})}}}function Kd(e){return typeof e==`object`&&!!e&&`errors`in e}function qd(e){return e!=null&&typeof e.toString==`function`}function Jd(e){return e instanceof S}function Yd(e){return e instanceof S?e.originalError==null?!0:Yd(e.originalError):!1}function Xd(e){return typeof e==`object`&&e?.constructor?.name===`DOMException`&&(e.name===`AbortError`||e.name===`TimeoutError`)}function Zd(e,t,n){let r=new Set;if(Kd(e))for(let i of e.errors){let e=Zd(i,t,n);for(let t of e)r.add(t)}else if(Xd(e))n.debug(`Request aborted`);else if(t){let i=t.maskError(e,t.errorMessage,t.isDev);i!==e&&n.error(e),r.add(Jd(i)?i:P(i.message,{originalError:i}))}else Jd(e)?r.add(e):e instanceof Error?r.add(P(e.message,{originalError:e})):typeof e==`string`?r.add(P(e,{extensions:{code:`INTERNAL_SERVER_ERROR`,unexpected:!0}})):qd(e)?r.add(P(e.toString(),{extensions:{code:`INTERNAL_SERVER_ERROR`,unexpected:!0}})):(n.error(e),r.add(P(`Unexpected error.`,{extensions:{http:{unexpected:!0}}})));return Array.from(r)}function Qd(e,t={},n=!1){let r,i=!1;if(`extensions`in e&&e.extensions?.http&&(e.extensions.http.headers&&Object.assign(t,e.extensions.http.headers),e.extensions.http.status&&(r=e.extensions.http.status)),`errors`in e&&e.errors?.length)for(let a of e.errors)if(a.extensions?.http){if(a.extensions.http.headers&&Object.assign(t,a.extensions.http.headers),n&&a.extensions.http.spec)continue;a.extensions.http.status&&(!r||a.extensions.http.status>r)&&(r=a.extensions.http.status)}else(!Yd(a)||a.extensions?.unexpected)&&(i=!0);else r||=200;return r||=i&&!(`data`in e)?500:200,{status:r,headers:t}}function $d(e){return Array.isArray(e)&&e.length>0&&e.some(Jd)}function ef(e){let t=e.get(`operationName`)||void 0,n=e.get(`query`)||void 0,r=e.get(`variables`)||void 0,i=e.get(`extensions`)||void 0;return{operationName:t,query:n,variables:r?JSON.parse(r):void 0,extensions:i?JSON.parse(i):void 0}}function tf(e){return ef(new zd.URLSearchParams(e))}function nf(e,t){let n=e.headers.get(`content-type`);return n=n?.split(`,`)[0]||null,n===t||!!n?.startsWith(`${t};`)}function rf(e){return e.method===`GET`}function af(e){return ef(new zd.URLSearchParams(e.url.substring(e.url.indexOf(`?`)+1)))}function of(e){return e.method===`POST`&&nf(e,`application/x-www-form-urlencoded`)}function sf(e){return e.text().then(tf)}function cf(e){return e.method===`POST`&&nf(e,`application/graphql`)}function lf(e){return e.text().then(e=>({query:e}))}function uf(e){return e.method===`POST`&&(nf(e,`application/json`)||nf(e,`application/graphql+json`))}function df(e){return F(()=>e.json(),e=>{if(e==null)throw P(`POST body is expected to be object but received ${e}`,{extensions:{http:{status:400},code:`BAD_REQUEST`}});let t=typeof e;if(t!==`object`)throw P(`POST body is expected to be object but received ${t}`,{extensions:{http:{status:400},code:`BAD_REQUEST`}});return e},e=>{if(e instanceof S)throw e;let t={http:{spec:!0,status:400},code:`BAD_REQUEST`};throw e instanceof Error&&(t.originalError={name:e.name,message:e.message}),P(`POST body sent invalid JSON.`,{extensions:t})})}function ff(e,t,n){t.split&&(t=t.split(`.`));for(var r=0,i=t.length,a=e,o,s;r<i&&(s=``+t[r++],!(s===`__proto__`||s===`constructor`||s===`prototype`));)a=a[s]=r===i?n:typeof(o=a[s])==typeof t?o:t[r]*0!=0||~(``+t[r]).indexOf(`.`)?{}:[]}function pf(e){return e.method===`POST`&&nf(e,`multipart/form-data`)}function mf(e){return F(()=>e.formData(),e=>{let t=e.get(`operations`);if(!t)throw P(`Missing multipart form field "operations"`);if(typeof t!=`string`)throw P(`Multipart form field "operations" must be a string`);let n;try{n=JSON.parse(t)}catch{throw P(`Multipart form field "operations" must be a valid JSON string`)}let r=e.get(`map`);if(r!=null){if(typeof r!=`string`)throw P(`Multipart form field "map" must be a string`);let t;try{t=JSON.parse(r)}catch{throw P(`Multipart form field "map" must be a valid JSON string`)}for(let r in t){let i=e.get(r),a=t[r];for(let e of a)ff(n,e,i)}}return n},e=>{throw e instanceof Error&&e.message.startsWith(`File size limit exceeded: `)?P(e.message,{extensions:{http:{status:413}}}):e})}const hf=new Set([`query`,`variables`,`operationName`,`extensions`]);function gf(e,t){if(typeof e!=`object`||!e)throw P(`Invalid "params" in the request body`,{extensions:{http:{spec:!0,status:400},code:`BAD_REQUEST`}});for(let n in e)if(e[n]!=null&&!hf.has(n)){if(t?.includes(n))continue;throw P(`Unexpected parameter "${n}" in the request body.`,{extensions:{http:{status:400},code:`BAD_REQUEST`}})}}function _f(e,t){if(!bf(e))throw P(`Expected params to be an object but given ${yf(e)}.`,{extensions:{http:{status:400,headers:{Allow:`GET, POST`}},code:`BAD_REQUEST`}});if(gf(e,t),e.query==null)throw P(`Must provide query string.`,{extensions:{http:{spec:!0,status:400,headers:{Allow:`GET, POST`}},code:`BAD_REQUEST`}});let n=yf(e.query);if(n!==`string`)throw P(`Expected "query" param to be a string, but given ${n}.`,{extensions:{http:{status:400,headers:{Allow:`GET, POST`}},code:`BAD_REQUEST`}});let r=yf(e.variables);if(![`object`,`null`,`undefined`].includes(r))throw P(`Expected "variables" param to be empty or an object, but given ${r}.`,{extensions:{http:{status:400,headers:{Allow:`GET, POST`}},code:`BAD_REQUEST`}});let i=yf(e.extensions);if(![`object`,`null`,`undefined`].includes(i))throw P(`Expected "extensions" param to be empty or an object, but given ${i}.`,{extensions:{http:{status:400,headers:{Allow:`GET, POST`}},code:`BAD_REQUEST`}});return e}function vf(e){return{onParams({params:t}){_f(t,e)}}}function yf(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function bf(e){return yf(e)===`object`}function xf(e){return e===`GET`||e===`POST`}function Sf(){return{onRequestParse({request:e}){if(!xf(e.method))throw P(`GraphQL only supports GET and POST requests.`,{extensions:{http:{status:405,headers:{Allow:`GET, POST`}},code:`BAD_REQUEST`}})}}}function Cf(){return{onValidate(){return({valid:e,result:t})=>{if(!e)for(let e of t)e.extensions||={},e.extensions.code||=`GRAPHQL_VALIDATION_FAILED`,e.extensions.http||={},e.extensions.http.spec=e.extensions.http.spec==null?!0:e.extensions.http.spec,e.extensions.http.status||=400}}}}function wf(e){return{onRequestParse(){return{onRequestParseDone({requestParserResult:t}){if(Array.isArray(t)){if(!e)throw P(`Batching is not supported.`,{extensions:{http:{status:400},code:`BAD_REQUEST`}});if(t.length>e)throw P(`Batching is limited to ${e} operations per request.`,{extensions:{http:{status:413},code:`BAD_REQUEST`}})}}}}}}function Tf(e,t,n){let r=t?_a(t,n)??void 0:void 0;if(!r)throw P(`Could not determine what operation to execute.`,{extensions:{code:`OPERATION_RESOLUTION_FAILURE`,http:{status:400}}});if(r.operation===`mutation`&&e===`GET`)throw P(`Can only perform a mutation operation from a POST request.`,{extensions:{http:{status:405,headers:{Allow:`POST`}},code:`BAD_REQUEST`}})}function Ef(){return{onParse(){return({result:e,context:{request:t,params:{operationName:n}={}}})=>{if(t)if(e instanceof Error){if(e instanceof S){let t=e.extensions||={};t.code||=`GRAPHQL_PARSE_FAILED`;let n=t.http||={};n.spec||=!0,n.status||=400}}else Tf(t.method,e,n)}}}}function Df({id:e=Date.now().toString(),logger:t=console,endpoint:n=`/health`}={}){return{onRequest({endResponse:r,fetchAPI:i,request:a}){a.url.endsWith(n)&&(t.debug(`Responding Health Check`),r(new i.Response(null,{status:200,headers:{"x-yoga-id":e}})))}}}const Of=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,kf=new Set,Af=typeof process==`object`&&process?process:{},jf=(e,t,n,r)=>{typeof Af.emitWarning==`function`?Af.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)};let Mf=globalThis.AbortController,Nf=globalThis.AbortSignal;if(Mf===void 0){Nf=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},Mf=class{constructor(){t()}signal=new Nf;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=Af.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,jf("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}const Pf=e=>!kf.has(e),Ff=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),If=e=>Ff(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?Lf:null:null;var Lf=class extends Array{constructor(e){super(e),this.fill(0)}},Rf=class e{heap;length;static#e=!1;static create(t){let n=If(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},zf=class e{#e;#t;#n;#r;#i;#a;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#y,sizes:e.#_,keyMap:e.#c,keyList:e.#l,valList:e.#u,next:e.#d,prev:e.#f,get head(){return e.#p},get tail(){return e.#m},free:e.#h,isBackgroundFetch:t=>e.#L(t),backgroundFetch:(t,n,r,i)=>e.#I(t,n,r,i),moveToTail:t=>e.#z(t),indexes:t=>e.#M(t),rindexes:t=>e.#N(t),isStale:t=>e.#D(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#s}get size(){return this.#o}get fetchMethod(){return this.#i}get memoMethod(){return this.#a}get dispose(){return this.#n}get disposeAfter(){return this.#r}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:f,maxSize:p=0,maxEntrySize:m=0,sizeCalculation:h,fetchMethod:g,memoMethod:_,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:S}=t;if(n!==0&&!Ff(n))throw TypeError(`max option must be a nonnegative integer`);let C=n?If(n):Array;if(!C)throw Error(`invalid max value: `+n);if(this.#e=n,this.#t=p,this.maxEntrySize=m||this.#t,this.sizeCalculation=h,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(_!==void 0&&typeof _!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#a=_,g!==void 0&&typeof g!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#i=g,this.#x=!!g,this.#c=new Map,this.#l=Array(n).fill(void 0),this.#u=Array(n).fill(void 0),this.#d=new C(n),this.#f=new C(n),this.#p=0,this.#m=0,this.#h=Rf.create(n),this.#o=0,this.#s=0,typeof l==`function`&&(this.#n=l),typeof u==`function`?(this.#r=u,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#b=!!this.#n,this.#S=!!this.#r,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!S,this.maxEntrySize!==0){if(this.#t!==0&&!Ff(this.#t))throw TypeError(`maxSize must be a positive integer if specified`);if(!Ff(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#O()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=Ff(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!Ff(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#C()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t=`LRU_CACHE_UNBOUNDED`;Pf(t)&&(kf.add(t),jf(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#C(){let e=new Lf(this.#e),t=new Lf(this.#e);this.#y=e,this.#v=t,this.#E=(n,r,i=Of.now())=>{if(t[n]=r===0?0:i,e[n]=r,r!==0&&this.ttlAutopurge){let e=setTimeout(()=>{this.#D(n)&&this.#B(this.#l[n],`expire`)},r+1);e.unref&&e.unref()}},this.#w=n=>{t[n]=e[n]===0?0:Of.now()},this.#T=(i,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;i.ttl=o,i.start=s,i.now=n||r(),i.remainingTTL=o-(i.now-s)}};let n=0,r=()=>{let e=Of.now();if(this.ttlResolution>0){n=e;let t=setTimeout(()=>n=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{let a=this.#c.get(i);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((n||r())-s)},this.#D=i=>{let a=t[i],o=e[i];return!!o&&!!a&&(n||r())-a>o}}#w=()=>{};#T=()=>{};#E=()=>{};#D=()=>!1;#O(){let e=new Lf(this.#e);this.#s=0,this.#_=e,this.#k=t=>{this.#s-=e[t],e[t]=0},this.#j=(e,t,n,r)=>{if(this.#L(t))return 0;if(!Ff(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!Ff(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.#A=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#s>n;)this.#F(!0)}this.#s+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#s)}}#k=e=>{};#A=(e,t,n)=>{};#j=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#M({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#m;!(!this.#P(t)||((e||!this.#D(t))&&(yield t),t===this.#p));)t=this.#f[t]}*#N({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#p;!(!this.#P(t)||((e||!this.#D(t))&&(yield t),t===this.#m));)t=this.#d[t]}#P(e){return e!==void 0&&this.#c.get(this.#l[e])===e}*entries(){for(let e of this.#M())this.#u[e]!==void 0&&this.#l[e]!==void 0&&!this.#L(this.#u[e])&&(yield[this.#l[e],this.#u[e]])}*rentries(){for(let e of this.#N())this.#u[e]!==void 0&&this.#l[e]!==void 0&&!this.#L(this.#u[e])&&(yield[this.#l[e],this.#u[e]])}*keys(){for(let e of this.#M()){let t=this.#l[e];t!==void 0&&!this.#L(this.#u[e])&&(yield t)}}*rkeys(){for(let e of this.#N()){let t=this.#l[e];t!==void 0&&!this.#L(this.#u[e])&&(yield t)}}*values(){for(let e of this.#M())this.#u[e]!==void 0&&!this.#L(this.#u[e])&&(yield this.#u[e])}*rvalues(){for(let e of this.#N())this.#u[e]!==void 0&&!this.#L(this.#u[e])&&(yield this.#u[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#M()){let r=this.#u[n],i=this.#L(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#l[n],this))return this.get(this.#l[n],t)}}forEach(e,t=this){for(let n of this.#M()){let r=this.#u[n],i=this.#L(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#l[n],this)}}rforEach(e,t=this){for(let n of this.#N()){let r=this.#u[n],i=this.#L(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#l[n],this)}}purgeStale(){let e=!1;for(let t of this.#N({allowStale:!0}))this.#D(t)&&(this.#B(this.#l[t],`expire`),e=!0);return e}info(e){let t=this.#c.get(e);if(t===void 0)return;let n=this.#u[t],r=this.#L(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#y&&this.#v){let e=this.#y[t],n=this.#v[t];e&&n&&(i.ttl=e-(Of.now()-n),i.start=Date.now())}return this.#_&&(i.size=this.#_[t]),i}dump(){let e=[];for(let t of this.#M({allowStale:!0})){let n=this.#l[t],r=this.#u[t],i=this.#L(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#y&&this.#v){a.ttl=this.#y[t];let e=Of.now()-this.#v[t];a.start=Math.floor(Date.now()-e)}this.#_&&(a.size=this.#_[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=Of.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#j(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#B(e,`set`),this;let u=this.#o===0?void 0:this.#c.get(e);if(u===void 0)u=this.#o===0?this.#m:this.#h.length===0?this.#o===this.#e?this.#F(!1):this.#o:this.#h.pop(),this.#l[u]=e,this.#u[u]=t,this.#c.set(e,u),this.#d[this.#m]=u,this.#f[u]=this.#m,this.#m=u,this.#o++,this.#A(u,l,s),s&&(s.set=`add`),c=!1;else{this.#z(u);let n=this.#u[u];if(t!==n){if(this.#x&&this.#L(n)){n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#b&&this.#n?.(t,e,`set`),this.#S&&this.#g?.push([t,e,`set`]))}else a||(this.#b&&this.#n?.(n,e,`set`),this.#S&&this.#g?.push([n,e,`set`]));if(this.#k(u),this.#A(u,l,s),this.#u[u]=t,s){s.set=`replace`;let e=n&&this.#L(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`)}if(r!==0&&!this.#y&&this.#C(),this.#y&&(c||this.#E(u,r,i),s&&this.#T(s,u)),!a&&this.#S&&this.#g){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}return this}pop(){try{for(;this.#o;){let e=this.#u[this.#p];if(this.#F(!0),this.#L(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#S&&this.#g){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}}}#F(e){let t=this.#p,n=this.#l[t],r=this.#u[t];return this.#x&&this.#L(r)?r.__abortController.abort(Error(`evicted`)):(this.#b||this.#S)&&(this.#b&&this.#n?.(r,n,`evict`),this.#S&&this.#g?.push([r,n,`evict`])),this.#k(t),e&&(this.#l[t]=void 0,this.#u[t]=void 0,this.#h.push(t)),this.#o===1?(this.#p=this.#m=0,this.#h.length=0):this.#p=this.#d[t],this.#c.delete(n),this.#o--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#c.get(e);if(i!==void 0){let e=this.#u[i];if(this.#L(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#D(i))r&&(r.has=`stale`,this.#T(r,i));else return n&&this.#w(i),r&&(r.has=`hit`,this.#T(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#c.get(e);if(r===void 0||!n&&this.#D(r))return;let i=this.#u[r];return this.#L(i)?i.__staleWhileFetching:i}#I(e,t,n,r){let i=t===void 0?void 0:this.#u[t];if(this.#L(i))return i;let a=new Mf,{signal:o}=n;o?.addEventListener(`abort`,()=>a.abort(o.reason),{signal:a.signal});let s={signal:a.signal,options:n,context:r},c=(r,i=!1)=>{let{aborted:o}=a.signal,c=n.ignoreFetchAbort&&r!==void 0;if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(a.signal.reason);let l=f;return this.#u[t]===f&&(r===void 0?l.__staleWhileFetching?this.#u[t]=l.__staleWhileFetching:this.#B(e,`fetch`):(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,s.options))),r},l=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e)),u=r=>{let{aborted:i}=a.signal,o=i&&n.allowStaleOnFetchAbort,s=o||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection,l=f;if(this.#u[t]===f&&(!c||l.__staleWhileFetching===void 0?this.#B(e,`fetch`):o||(this.#u[t]=l.__staleWhileFetching)),s)return n.status&&l.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw r},d=(t,r)=>{let o=this.#i?.(e,i,s);o&&o instanceof Promise&&o.then(e=>t(e===void 0?void 0:e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(c,l),p=Object.assign(f,{__abortController:a,__staleWhileFetching:i,__returned:void 0});return t===void 0?(this.set(e,p,{...s.options,status:void 0}),t=this.#c.get(e)):this.#u[t]=p,p}#L(e){if(!this.#x)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof Mf}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:_}=t;if(!this.#x)return g&&(g.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:_},y=this.#c.get(e);if(y===void 0){g&&(g.fetch=`miss`);let t=this.#I(e,y,v,m);return t.__returned=t}else{let t=this.#u[y];if(this.#L(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#D(y);if(!h&&!i)return g&&(g.fetch=`hit`),this.#z(y),r&&this.#w(y),g&&this.#T(g,y),t;let a=this.#I(e,y,v,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#a;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#c.get(e);if(o!==void 0){let t=this.#u[o],s=this.#L(t);return a&&this.#T(a,o),this.#D(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#B(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#z(o),r&&this.#w(o),t))}else a&&(a.get=`miss`)}#R(e,t){this.#f[t]=e,this.#d[e]=t}#z(e){e!==this.#m&&(e===this.#p?this.#p=this.#d[e]:this.#R(this.#f[e],this.#d[e]),this.#R(this.#m,e),this.#m=e)}delete(e){return this.#B(e,`delete`)}#B(e,t){let n=!1;if(this.#o!==0){let r=this.#c.get(e);if(r!==void 0)if(n=!0,this.#o===1)this.#V(t);else{this.#k(r);let n=this.#u[r];if(this.#L(n)?n.__abortController.abort(Error(`deleted`)):(this.#b||this.#S)&&(this.#b&&this.#n?.(n,e,t),this.#S&&this.#g?.push([n,e,t])),this.#c.delete(e),this.#l[r]=void 0,this.#u[r]=void 0,r===this.#m)this.#m=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{let e=this.#f[r];this.#d[e]=this.#d[r];let t=this.#d[r];this.#f[t]=this.#f[r]}this.#o--,this.#h.push(r)}}if(this.#S&&this.#g?.length){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}return n}clear(){return this.#V(`delete`)}#V(e){for(let t of this.#N({allowStale:!0})){let n=this.#u[t];if(this.#L(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#l[t];this.#b&&this.#n?.(n,r,e),this.#S&&this.#g?.push([n,r,e])}}if(this.#c.clear(),this.#u.fill(void 0),this.#l.fill(void 0),this.#y&&this.#v&&(this.#y.fill(0),this.#v.fill(0)),this.#_&&this.#_.fill(0),this.#p=0,this.#m=0,this.#h.length=0,this.#s=0,this.#o=0,this.#S&&this.#g){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}}};function Bf({max:e=1024,ttl:t=36e5}={}){return new zf({max:e,ttl:t})}function Vf({documentCache:e=Bf(),errorCache:t=Bf(),validationCache:n=!0}){let r=Bf();return{onParse({params:n,setParsedDocument:r}){let i=n.source.toString(),a=e.get(i);if(a){r(a);return}let o=t.get(i);if(o)throw o;return({result:n})=>{n!=null&&(n instanceof Error?t.set(i,n):e.set(i,n))}},onValidate({params:{schema:e,documentAST:t,rules:i},setResult:a}){if(e!=null&&n!==!1){let n=i?.map(e=>e.name).join(`,`)||``,o=r.get(n);o||(o=new WeakMap,r.set(n,o));let s=o.get(e);s||(s=new WeakMap,o.set(e,s));let c=s.get(t);if(c){a(c);return}return({result:e})=>{e!=null&&s?.set(t,e)}}}}}const Hf=()=>!0;function Uf(e){let t=e.match||Hf;return{onRequestParse({request:n,setRequestParser:r}){t(n)&&r(e.parse)}}}function Wf(e){let t=(e.headers.get(`accept`)||`*/*`).replace(/\s/g,``).toLowerCase().split(`,`),n=[];for(let e of t){let[t,...r]=e.split(`;`);t!==void 0&&(r?.find(e=>e.includes(`charset=`))||`charset=utf-8`)===`charset=utf-8`&&n.push(t)}return n.reverse()}function Gf(e,t){let[n,r]=e.split(`/`),[i,a]=t.split(`/`);return(i===`*`||i===n)&&(a===`*`||a===r)}function Kf(e){if(Array.isArray(e))return`[${e.map(e=>{let t=qf(e);return(e.stringify||JSON.stringify)(t)}).join(`,`)}]`;let t=qf(e);return(e.stringify||JSON.stringify)(t)}function qf(e){if(e.errors?.length||e.extensions?.http){let t={...e};if(t.errors&&=t.errors.map(Jf),t.extensions){let{http:n,...r}=e.extensions;t.extensions=Object.keys(r).length?r:void 0}return t}return e}function Jf(e){if(Jd(e)){let{http:t,unexpected:n,...r}=(`toJSON`in e&&typeof e.toJSON==`function`?e.toJSON():Object(e)).extensions||{};return P(e.message,{nodes:e.nodes,source:e.source,positions:e.positions,path:e.path,originalError:Jf(e.originalError||void 0),extensions:Object.keys(r).length?r:void 0})}return e}function Yf(e,t){let n=Qd(e,{Connection:`keep-alive`,"Content-Type":`multipart/mixed; boundary="-"`,"Transfer-Encoding":`chunked`}),r,i=new t.TextEncoder,a=new t.ReadableStream({start(t){if(Fl(e))r=e[Symbol.asyncIterator]();else{let t=!1;r={next:()=>t?Ha({done:!0,value:null}):(t=!0,Ha({done:!1,value:e}))}}t.enqueue(i.encode(`\r
81
+ `)),t.enqueue(i.encode(`---`))},pull(e){return F(()=>r.next(),({done:t,value:n})=>{if(n!=null){e.enqueue(i.encode(`\r
82
+ `)),e.enqueue(i.encode(`Content-Type: application/json; charset=utf-8`)),e.enqueue(i.encode(`\r
83
+ `));let t=Kf(n),r=i.encode(t);e.enqueue(i.encode(`Content-Length: `+r.byteLength)),e.enqueue(i.encode(`\r
84
+ `)),e.enqueue(i.encode(`\r
85
+ `)),e.enqueue(r),e.enqueue(i.encode(`\r
86
+ `)),e.enqueue(i.encode(`---`))}t&&(e.enqueue(i.encode(`--\r
87
+ `)),e.close())},t=>{e.error(t)})},cancel(e){if(r.return)return F(()=>r.return?.(e),()=>{})}});return new t.Response(a,n)}function Xf(e,t,n){if(Us(e))return new t.Response(null,{status:406,statusText:`Not Acceptable`,headers:{accept:`application/json; charset=utf-8, application/graphql-response+json; charset=utf-8`}});let r=Qd(e,{"Content-Type":n+`; charset=utf-8`},n===`application/json`&&!Array.isArray(e)&&$d(e.errors)&&e.errors.some(e=>!e.extensions?.originalError||Jd(e.extensions.originalError))),i=Kf(e);return new t.Response(i,r)}function Zf(){return function(e,t){let n=Qd(e,{"Content-Type":`text/event-stream`,Connection:`keep-alive`,"Cache-Control":`no-cache`,"Content-Encoding":`none`},!0),r,i,a=new t.TextEncoder,o=new t.ReadableStream({start(t){if(t.enqueue(a.encode(`:
88
+
89
+ `)),i=setInterval(()=>{if(!t.desiredSize){clearInterval(i);return}t.enqueue(a.encode(`:
90
+
91
+ `))},12e3),Fl(e))r=e[Symbol.asyncIterator]();else{let t=!1;r={next:()=>t?Ha({done:!0,value:null}):(t=!0,Ha({done:!1,value:e}))}}},pull(e){return F(()=>r.next(),t=>{if(t.value!=null){e.enqueue(a.encode(`event: next
92
+ `));let n=Kf(t.value);e.enqueue(a.encode(`data: ${n}\n\n`))}t.done&&(e.enqueue(a.encode(`event: complete
93
+ `)),e.enqueue(a.encode(`data:
94
+
95
+ `)),clearInterval(i),e.close())},t=>{e.error(t)})},cancel(e){if(clearInterval(i),r.return)return F(()=>r.return?.(e),()=>{})}});return new t.Response(o,n)}}const Qf={mediaTypes:[`multipart/mixed`],asyncIterables:!0,processResult:Yf};function $f(){return{mediaTypes:[`text/event-stream`],asyncIterables:!0,processResult:Zf()}}const ep={mediaTypes:[`application/graphql-response+json`,`application/json`],asyncIterables:!1,processResult:Xf};function tp(){let e=new WeakMap,t=$f(),n=[t,Qf,ep],r=[t,ep];return{onSubscribe({args:{contextValue:t}}){t.request&&e.set(t.request,!0)},onResultProcess({request:t,result:i,acceptableMediaTypes:a,setResultProcessor:o}){let s=e.get(t)?r:n,c=Wf(t),l=Fl(i);for(let e of s)for(let t of c)if(!(l&&!e.asyncIterables))for(let n of e.mediaTypes)a.push(n),Gf(n,t)&&o(e.processResult,n)}}}var np=`<!doctype html><html lang=en><head><meta charset=utf-8><title>Welcome to GraphQL Yoga</title><link rel=icon href=https://raw.githubusercontent.com/graphql-hive/graphql-yoga/refs/heads/main/website/src/app/favicon.ico><style>body,html{padding:0;margin:0;height:100%;font-family:Inter,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen,Ubuntu,Cantarell,'Fira Sans','Droid Sans','Helvetica Neue',sans-serif;color:#fff;background-color:#000}main>section.hero{display:flex;height:90vh;justify-content:center;align-items:center;flex-direction:column}.logo{display:flex;align-items:center}.buttons{margin-top:24px}h1{font-size:80px}h2{color:#888;max-width:50%;margin-top:0;text-align:center}a{color:#fff;text-decoration:none;margin-left:10px;margin-right:10px;font-weight:700;transition:color .3s ease;padding:4px;overflow:visible}a.graphiql:hover{color:rgba(255,0,255,.7)}a.docs:hover{color:rgba(28,200,238,.7)}a.tutorial:hover{color:rgba(125,85,245,.7)}svg{margin-right:24px}.not-what-your-looking-for{margin-top:5vh}.not-what-your-looking-for>*{margin-left:auto;margin-right:auto}.not-what-your-looking-for>p{text-align:center}.not-what-your-looking-for>h2{color:#464646}.not-what-your-looking-for>p{max-width:600px;line-height:1.3em}.not-what-your-looking-for>pre{max-width:300px}</style></head><body id=body><main><section class=hero><div class=logo><div><svg xmlns=http://www.w3.org/2000/svg viewBox="-0.41 0.445 472.812 499.811" height=150><defs><linearGradient id=paint0_linear_1677_11483 x1=16 y1=14 x2=87.2132 y2=44.5982 gradientUnits=userSpaceOnUse gradientTransform="matrix(8.139854, 0, 0, 8.139854, -130.346407, -113.25101)"><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><linearGradient id=paint1_linear_1677_11483 x1=16 y1=14 x2=87.2132 y2=44.5982 gradientUnits=userSpaceOnUse gradientTransform="matrix(8.139854, 0, 0, 8.139854, -130.346407, -113.25101)"><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><linearGradient id=paint2_linear_1677_11483 x1=16 y1=14 x2=87.2132 y2=44.5982 gradientUnits=userSpaceOnUse gradientTransform="matrix(8.139854, 0, 0, 8.139854, -130.346407, -113.25101)"><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><linearGradient id=paint3_linear_1677_11483 x1=16 y1=14 x2=87.2132 y2=44.5982 gradientUnits=userSpaceOnUse><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><linearGradient id=paint4_linear_1677_11483 x1=16 y1=14 x2=87.2132 y2=44.5982 gradientUnits=userSpaceOnUse><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><linearGradient id=paint5_linear_1677_11483 x1=16 y1=14 x2=87.2132 y2=44.5982 gradientUnits=userSpaceOnUse><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><filter id=filter0_f_1677_11483 x=23 y=-25 width=100 height=100 filterUnits=userSpaceOnUse color-interpolation-filters=sRGB><feFlood flood-opacity=0 result=BackgroundImageFix /><feBlend mode=normal in=SourceGraphic in2=BackgroundImageFix result=shape /><feGaussianBlur stdDeviation=12 result=effect1_foregroundBlur_1677_11483 /></filter><filter id=filter1_f_1677_11483 x=-24 y=19 width=100 height=100 filterUnits=userSpaceOnUse color-interpolation-filters=sRGB><feFlood flood-opacity=0 result=BackgroundImageFix /><feBlend mode=normal in=SourceGraphic in2=BackgroundImageFix result=shape /><feGaussianBlur stdDeviation=12 result=effect1_foregroundBlur_1677_11483 /></filter><linearGradient id=paint6_linear_1677_11483 x1=30 y1=28 x2=66.1645 y2=44.4363 gradientUnits=userSpaceOnUse gradientTransform="matrix(8.139854, 0, 0, 8.139854, -130.346407, -113.25101)"><stop stop-color=#7433FF /><stop offset=1 stop-color=#FFA3FD /></linearGradient><filter id=filter2_f_1677_11483 x=-12 y=-44 width=100 height=100 filterUnits=userSpaceOnUse color-interpolation-filters=sRGB><feFlood flood-opacity=0 result=BackgroundImageFix /><feBlend mode=normal in=SourceGraphic in2=BackgroundImageFix result=shape /><feGaussianBlur stdDeviation=12 result=effect1_foregroundBlur_1677_11483 /></filter><filter id=filter3_f_1677_11483 x=13 y=19 width=100 height=100 filterUnits=userSpaceOnUse color-interpolation-filters=sRGB><feFlood flood-opacity=0 result=BackgroundImageFix /><feBlend mode=normal in=SourceGraphic in2=BackgroundImageFix result=shape /><feGaussianBlur stdDeviation=12 result=effect1_foregroundBlur_1677_11483 /></filter></defs><mask id=mask0_1677_11483 style=mask-type:alpha maskUnits=userSpaceOnUse x=16 y=14 width=58 height=62><path d="M21 25.3501C21.7279 25.3501 22.4195 25.5056 23.0433 25.7853L42.1439 14.8C43.0439 14.3 44.1439 14 45.1439 14C46.2439 14 47.2439 14.3 48.1439 14.8L64.5439 24.3C63.3439 25.1 62.4439 26.3 61.8439 27.7L45.9438 18.5C45.6439 18.3 45.344 18.3 45.0441 18.3C44.7441 18.3 44.4439 18.4 44.1439 18.5L25.8225 29.0251C25.9382 29.4471 26 29.8914 26 30.3501C26 33.1115 23.7614 35.3501 21 35.3501C18.2386 35.3501 16 33.1115 16 30.3501C16 27.5887 18.2386 25.3501 21 25.3501Z" fill=url(#paint3_linear_1677_11483) /><path d="M67.2438 35.0329C65.3487 34.3219 64 32.4934 64 30.35C64 27.5886 66.2386 25.35 69 25.35C71.7614 25.35 74 27.5886 74 30.35C74 32.1825 73.0142 33.7848 71.5439 34.6554V55.2C71.5439 57.4 70.3439 59.4 68.5439 60.5L52.1439 69.9C52.1439 68.4 51.6438 66.9 50.7438 65.8L66.3439 56.8C66.9439 56.5 67.2438 55.9 67.2438 55.2V35.0329Z" fill=url(#paint4_linear_1677_11483) /><path d="M49.8439 69.1055C49.9458 69.5034 50 69.9204 50 70.3501C50 73.1115 47.7614 75.3501 45 75.3501C42.5102 75.3501 40.4454 73.5302 40.0633 71.1481L21.8439 60.6C19.9439 59.5 18.8439 57.5 18.8439 55.3V36.8C19.5439 37 20.3439 37.2 21.0439 37.2C21.7439 37.2 22.4439 37.1 23.0439 36.9V55.3C23.0439 56 23.4438 56.6 23.9438 56.9L41.3263 66.9583C42.2398 65.9694 43.5476 65.3501 45 65.3501C47.3291 65.3501 49.2862 66.9426 49.8419 69.0981L49.8436 69.0997L49.8439 69.1055Z" fill=url(#paint5_linear_1677_11483) /></mask><mask id=mask1_1677_11483 style=mask-type:alpha maskUnits=userSpaceOnUse x=30 y=28 width=30 height=30><path fill-rule=evenodd clip-rule=evenodd d="M49.3945 32.3945C49.3945 34.7088 47.5796 38.5469 45 38.5469C42.4271 38.5469 40.6055 34.7112 40.6055 32.3945C40.6055 29.9714 42.5769 28 45 28C47.4231 28 49.3945 29.9714 49.3945 32.3945ZM35.332 49.0433V48.2148C35.332 42.8117 37.8535 41.0004 39.8796 39.545L39.8801 39.5447C40.3928 39.1767 40.8604 38.8404 41.2488 38.4742C42.3293 39.6642 43.626 40.3047 45 40.3047C46.3752 40.3047 47.6725 39.6642 48.7529 38.4754C49.1408 38.841 49.6078 39.1773 50.1199 39.5447L50.1204 39.545C52.1465 41.0004 54.668 42.8117 54.668 48.2148V49.0433L53.8406 49.092C49.9848 49.3185 46.8646 46.9002 45 43.5777C43.1159 46.935 39.9847 49.318 36.1594 49.092L35.332 49.0433ZM58.1463 51.0747L58.1463 51.0746C57.0179 50.891 50.0128 49.7507 45.0007 55.693C40.0116 49.7553 33.1965 50.8592 31.9095 51.0677L31.9095 51.0677C31.7906 51.087 31.7189 51.0986 31.7002 51.0963C31.7005 51.0969 31.7011 51.1045 31.7023 51.1187C31.726 51.4003 31.9682 54.2745 34.0566 56.2422L30 58H60L55.8956 56.2422C57.8537 54.4764 58.1396 52.2685 58.2508 51.4092V51.4091C58.2697 51.2628 58.2836 51.1556 58.2998 51.0963C58.2881 51.0977 58.2356 51.0892 58.1463 51.0747ZM40.4836 50.104C42.3956 49.3212 43.6746 48.1737 45 46.61C46.332 48.1841 47.6159 49.3259 49.5164 50.104C49.5356 50.1425 49.5557 50.1805 49.5756 50.2182C49.5793 50.2253 49.583 50.2323 49.5867 50.2393C48.0911 50.8127 46.4264 51.825 45.0047 53.1444C43.5906 51.8221 41.9673 50.8196 40.4256 50.2153C40.4455 50.1784 40.4648 50.1415 40.4836 50.104Z" fill=black /></mask><path d="M 40.59 93.095 C 46.517 93.095 52.14 94.365 57.22 96.635 L 212.7 7.22 C 220.025 3.149 228.978 0.706 237.12 0.706 C 246.073 0.706 254.213 3.149 261.54 7.22 L 395.032 84.547 C 385.264 91.059 377.939 100.827 373.055 112.224 L 243.631 37.338 C 241.19 35.71 238.747 35.71 236.305 35.71 C 233.863 35.71 231.42 36.523 228.978 37.338 L 79.84 123.009 C 80.786 126.443 81.29 130.058 81.29 133.793 C 81.29 156.269 63.065 174.493 40.59 174.493 C 18.116 174.493 -0.109 156.269 -0.109 133.793 C -0.109 111.32 18.116 93.095 40.59 93.095 Z" fill=url(#paint0_linear_1677_11483) /><path d="M 417.01 171.913 C 401.585 166.126 390.603 151.238 390.603 133.793 C 390.603 111.32 408.83 93.095 431.303 93.095 C 453.777 93.095 472.001 111.32 472.001 133.793 C 472.001 148.706 463.976 161.755 452.011 168.835 L 452.011 336.07 C 452.011 353.977 442.243 370.258 427.591 379.21 L 294.098 455.726 C 294.098 443.516 290.029 431.306 282.703 422.353 L 409.683 349.093 C 414.568 346.651 417.01 341.767 417.01 336.07 L 417.01 171.913 Z" fill=url(#paint1_linear_1677_11483) /><path d="M 275.376 449.253 C 276.206 452.495 276.646 455.889 276.646 459.389 C 276.646 481.863 258.422 500.087 235.947 500.087 C 215.679 500.087 198.87 485.272 195.761 465.883 L 47.46 380.025 C 31.995 371.071 23.041 354.792 23.041 336.884 L 23.041 186.296 C 28.738 187.923 35.25 189.553 40.948 189.553 C 46.646 189.553 52.345 188.738 57.228 187.111 L 57.228 336.884 C 57.228 342.582 60.485 347.465 64.554 349.908 L 206.042 431.777 C 213.481 423.728 224.127 418.689 235.947 418.689 C 254.905 418.689 270.833 431.656 275.36 449.196 L 275.376 449.214 L 275.376 449.253 Z" fill=url(#paint2_linear_1677_11483) /><g mask=url(#mask0_1677_11483) transform="matrix(8.139854, 0, 0, 8.139854, -130.346375, -113.251038)"><g filter=url(#filter0_f_1677_11483)><circle cx=73 cy=25 r=26 fill=#ED2E7E /></g><g filter=url(#filter1_f_1677_11483)><circle cx=26 cy=69 r=26 fill=#1CC8EE /></g></g><path fill-rule=evenodd clip-rule=evenodd d="M 271.713 150.431 C 271.713 169.275 256.948 200.517 235.947 200.517 C 215.003 200.517 200.172 169.292 200.172 150.431 C 200.172 130.708 216.225 114.666 235.947 114.666 C 255.67 114.666 271.713 130.708 271.713 150.431 Z M 157.251 285.952 L 157.251 279.212 C 157.251 235.233 177.771 220.485 194.27 208.641 C 198.447 205.644 202.247 202.901 205.414 199.923 C 214.204 209.608 224.763 214.826 235.947 214.826 C 247.138 214.826 257.697 209.608 266.496 199.931 C 269.653 202.911 273.456 205.644 277.622 208.641 C 294.114 220.485 314.642 235.233 314.642 279.212 L 314.642 285.952 L 307.912 286.351 C 276.525 288.191 251.128 268.509 235.947 241.468 C 220.611 268.795 195.126 288.191 163.981 286.351 L 157.251 285.952 Z M 342.953 302.492 C 333.771 300.994 276.751 291.715 235.955 340.082 C 195.345 291.749 139.865 300.734 129.389 302.436 C 128.428 302.59 127.841 302.688 127.687 302.665 C 127.687 302.673 127.695 302.729 127.702 302.85 C 127.897 305.138 129.867 328.532 146.872 344.55 L 113.849 358.862 L 358.044 358.862 L 324.639 344.55 C 340.576 330.177 342.905 312.202 343.807 305.212 C 343.962 304.022 344.077 303.153 344.206 302.665 C 344.108 302.68 343.686 302.606 342.953 302.492 Z M 199.188 294.59 C 214.751 288.215 225.161 278.879 235.947 266.15 C 246.788 278.96 257.241 288.255 272.707 294.59 C 272.869 294.898 273.031 295.207 273.196 295.518 C 273.219 295.574 273.252 295.631 273.285 295.688 C 261.107 300.361 247.555 308.598 235.989 319.334 C 224.477 308.573 211.258 300.417 198.715 295.493 C 198.87 295.191 199.033 294.891 199.188 294.59 Z" fill=url(#paint6_linear_1677_11483) /><g mask=url(#mask1_1677_11483) transform="matrix(8.139854, 0, 0, 8.139854, -130.346375, -113.251038)"><g filter=url(#filter2_f_1677_11483)><circle cx=38 cy=6 r=26 fill=#ED2E7E /></g><g filter=url(#filter3_f_1677_11483)><circle cx=63 cy=69 r=26 fill=#1CC8EE /></g></g></svg></div><h1>GraphQL Yoga</h1><p>Version: 5.15.2</p></div><h2>The batteries-included cross-platform GraphQL Server.</h2><div class=buttons><a href=https://www.the-guild.dev/graphql/yoga-server/docs class=docs>Read the Docs</a> <a href=https://www.the-guild.dev/graphql/yoga-server/tutorial/basic class=tutorial>Start the Tutorial </a><a href=__GRAPHIQL_LINK__ class=graphiql>Visit GraphiQL</a></div></section><section class=not-what-your-looking-for><h2>Not the page you are looking for? 👀</h2><p>This page is shown be default whenever a 404 is hit.<br>You can disable this by behavior via the <code>landingPage</code> option.</p><pre>
96
+ <code>
97
+ import { createYoga } from 'graphql-yoga';
98
+
99
+ const yoga = createYoga({
100
+ landingPage: false
101
+ })
102
+ </code>
103
+ </pre><p>If you expected this page to be the GraphQL route, you need to configure Yoga. Currently, the GraphQL route is configured to be on <code>__GRAPHIQL_LINK__</code>.</p><pre>
104
+ <code>
105
+ import { createYoga } from 'graphql-yoga';
106
+
107
+ const yoga = createYoga({
108
+ graphqlEndpoint: '__REQUEST_PATH__',
109
+ })
110
+ </code>
111
+ </pre></section></main></body></html>`;const rp=function(e){return new e.fetchAPI.Response(np.replace(/__GRAPHIQL_LINK__/g,e.graphqlEndpoint).replace(/__REQUEST_PATH__/g,e.url.pathname),{status:200,statusText:`OK`,headers:{"Content-Type":`text/html`}})};function ip(e){let t;function n({URLPattern:n}){return t||=new n({pathname:e.graphqlEndpoint}),t}let r=e.landingPageRenderer||rp;return{onRequest({request:t,fetchAPI:i,endResponse:a,url:o}){if(!t.url.endsWith(e.graphqlEndpoint)&&!t.url.endsWith(`${e.graphqlEndpoint}/`)&&o.pathname!==e.graphqlEndpoint&&o.pathname!==`${e.graphqlEndpoint}/`&&!n(i).test(o)){if(e.showLandingPage===!0&&t.method===`GET`&&t.headers?.get(`accept`)?.includes(`text/html`)){let s=r({request:t,fetchAPI:i,url:o,graphqlEndpoint:e.graphqlEndpoint,get urlPattern(){return n(i)}});if(Va(s))return s.then(a);a(s);return}a(new i.Response(``,{status:404,statusText:`Not Found`}))}}}}function ap({request:e,result:t,fetchAPI:n,onResultProcessHooks:r,serverContext:i}){let a,o=[],s=`*/*`;return F(()=>Wa(r,n=>n({request:e,acceptableMediaTypes:o,result:t,setResult(e){t=e},resultProcessor:a,setResultProcessor(e,t){a=e,s=t},serverContext:i})),()=>a?a(t,n,s):new n.Response(null,{status:406,statusText:`Not Acceptable`,headers:{accept:o.join(`; charset=utf-8, `)}}))}function op({params:e,enveloped:t}){let n=t.parse(e.query),r=t.validate(t.schema,n);return r.length>0?{errors:r}:F(()=>t.contextFactory(),r=>{let i={schema:t.schema,document:n,contextValue:r,variableValues:e.variables,operationName:e.operationName};return(_a(n,e.operationName)?.operation===`subscription`?t.subscribe:t.execute)(i)})}function sp(e){return Jd(e)?e.toJSON():e instanceof Error?{message:e.message,stack:e.stack,cause:e.cause}:e}const cp=(e,t,n=!1)=>{if(Yd(e))return e;let r={code:`INTERNAL_SERVER_ERROR`,unexpected:!0},i={extensions:r};return Jd(e)?(i.nodes=e.nodes,i.source=e.source,i.positions=e.positions,i.path=e.path,n&&e.originalError&&(r.originalError=sp(e.originalError)),e.extensions?.http&&(r.http=e.extensions.http)):n&&(r.originalError=sp(e)),P(t,i)};var lp=class{getEnveloped;logger;graphqlEndpoint;fetchAPI;plugins;instrumentation;onRequestParseHooks;onParamsHooks;onExecutionResultHooks;onResultProcessHooks;maskedErrorsOpts;id;version=`5.15.2`;constructor(e){if(this.id=e?.id??`yoga`,this.fetchAPI={...zd},e?.fetchAPI)for(let t in e.fetchAPI)e.fetchAPI[t]&&(this.fetchAPI[t]=e.fetchAPI[t]);let t=e?.logging==null?!0:e.logging;this.logger=typeof t==`boolean`?t===!0?lc():lc(`silent`):typeof t==`string`?lc(t):t;let n=typeof e?.maskedErrors==`object`&&e.maskedErrors.maskError||cp,r=new WeakSet;this.maskedErrorsOpts=e?.maskedErrors===!1?null:{errorMessage:`Unexpected error.`,...typeof e?.maskedErrors==`object`?e.maskedErrors:{},maskError:(e,t)=>{if(r.has(e))return e;let i=n(e,t,this.maskedErrorsOpts?.isDev);return i!==e&&this.logger.error(e),r.add(i),i}};let i=this.maskedErrorsOpts==null?null:this.maskedErrorsOpts,a=0;e?.batching&&(a=typeof e.batching==`boolean`?10:e.batching.limit??10),this.graphqlEndpoint=e?.graphqlEndpoint||`/graphql`;let o=this.graphqlEndpoint;this.plugins=[Ql({parse:He,validate:la,execute:id,subscribe:id,specifiedRules:ia}),!!e?.schema&&mc(e.schema),e?.context!=null&&Zl(t=>e?.context?typeof e.context==`function`?e.context(t):e.context:{}),Df({id:this.id,logger:this.logger,endpoint:e?.healthCheckEndpoint}),e?.cors!==!1&&Gd(e?.cors),e?.graphiql!==!1&&pc({graphqlEndpoint:o,options:e?.graphiql,render:e?.renderGraphiQL,logger:this.logger}),Uf({match:rf,parse:af}),Uf({match:uf,parse:df}),e?.multipart!==!1&&Uf({match:pf,parse:mf}),Uf({match:cf,parse:lf}),Uf({match:of,parse:sf}),tp(),...e?.plugins??[],{onPluginInit({addPlugin:t}){e?.parserAndValidationCache!==!1&&t(Vf(!e?.parserAndValidationCache||e?.parserAndValidationCache===!0?{}:e?.parserAndValidationCache)),t(wf(a)),t(vf(e?.extraParamNames));let n=!!(e?.landingPage??!0);t(ip({graphqlEndpoint:o,showLandingPage:n,landingPageRenderer:typeof e?.landingPage==`function`?e.landingPage:void 0})),t(Sf()),t(Ef()),i&&(t({onSubscribe(){return{onSubscribeError({error:e}){if(Xd(e))throw e}}}}),t(Jl(i))),t(Cf())}}],this.getEnveloped=Hl({plugins:this.plugins}),this.plugins=this.getEnveloped._plugins,this.onRequestParseHooks=[],this.onParamsHooks=[],this.onExecutionResultHooks=[],this.onResultProcessHooks=[];for(let e of this.plugins)e&&(e.onYogaInit&&e.onYogaInit({yoga:this}),e.onRequestParse&&this.onRequestParseHooks.push(e.onRequestParse),e.onParams&&this.onParamsHooks.push(e.onParams),e.onExecutionResult&&this.onExecutionResultHooks.push(e.onExecutionResult),e.onResultProcess&&this.onResultProcessHooks.push(e.onResultProcess),e.instrumentation&&(this.instrumentation=this.instrumentation?Dl(this.instrumentation,e.instrumentation):e.instrumentation))}handleParams=({request:e,context:t,params:n})=>{let r=t.request===e?{params:n}:{request:e,params:n};Object.assign(t,r);let i=this.getEnveloped(t);return this.logger.debug(`Processing GraphQL Parameters`),F(()=>F(()=>op({params:n,enveloped:i}),e=>(this.logger.debug(`Processing GraphQL Parameters done.`),e),e=>({errors:Zd(e,this.maskedErrorsOpts,this.logger)})),e=>(Fl(e)&&(e=qa(e,e=>e,e=>{if(e.name===`AbortError`)throw this.logger.debug(`Request aborted`),e;return{errors:Zd(e,this.maskedErrorsOpts,this.logger)}})),e))};getResultForParams=({params:e,request:t},n)=>{let r,i=this.handleParams;return F(()=>Wa(this.onParamsHooks,a=>a({params:e,request:t,setParams(t){e=t},paramsHandler:i,setParamsHandler(e){i=e},setResult(e){r=e},fetchAPI:this.fetchAPI,context:n})),()=>F(()=>r||i({request:t,params:e,context:n}),e=>F(()=>Wa(this.onExecutionResultHooks,r=>r({result:e,setResult(t){e=t},request:t,context:n})),()=>e)))};parseRequest=(e,t)=>{let n=new Proxy({},{get:(t,r,i)=>(n=new this.fetchAPI.URL(e.url,`http://localhost`),Reflect.get(n,r,n))}),r,i=[];return F(()=>Wa(this.onRequestParseHooks,i=>F(()=>i({request:e,url:n,requestParser:r,serverContext:t,setRequestParser(e){r=e}}),e=>e?.onRequestParseDone),i),()=>(this.logger.debug(`Parsing request to extract GraphQL parameters`),r?F(()=>r(e),e=>F(()=>Wa(i,t=>t({requestParserResult:e,setRequestParserResult(t){e=t}})),()=>({requestParserResult:e}))):{response:new this.fetchAPI.Response(null,{status:415,statusText:`Unsupported Media Type`})}))};handle=(e,t)=>{let n=this.instrumentation&&Ol({request:e}),r=this.instrumentation?.requestParse?n.asyncFn(this.instrumentation?.requestParse,this.parseRequest):this.parseRequest;return Qa(Ha().then(()=>r(e,t)).then(({response:r,requestParserResult:i})=>{if(r)return r;let a=this.instrumentation?.operation?(e,t)=>Ol({context:t,request:e.request}).asyncFn(this.instrumentation?.operation,this.getResultForParams)(e,t):this.getResultForParams;return F(()=>Array.isArray(i)?Promise.all(i.map(n=>a({params:n,request:e},Object.create(t)))):a({params:i,request:e},t),r=>(this.instrumentation?.resultProcess?n.asyncFn(this.instrumentation.resultProcess,ap):ap)({request:e,result:r,fetchAPI:this.fetchAPI,onResultProcessHooks:this.onResultProcessHooks,serverContext:t}))}).catch(n=>ap({request:e,result:{errors:Zd(n,this.maskedErrorsOpts,this.logger)},fetchAPI:this.fetchAPI,onResultProcessHooks:this.onResultProcessHooks,serverContext:t})))}};function up(e){let t=new lp(e);return Hd(t,{fetchAPI:t.fetchAPI,plugins:t.plugins,disposeOnProcessTerminate:e.disposeOnProcessTerminate})}function dp(){return{onExecute({args:e}){e.signal=e.contextValue?.request?.signal??void 0},onSubscribe({args:e}){e.signal=e.contextValue?.request?.signal??void 0}}}function fp(e){let t=Object.create(null);return{Directive(n){if(n.name.value===Ps.name||n.name.value===Fs.name){let r=n.arguments?.find(e=>e.name.value===`label`)?.value;if(!r)return;r.kind===E.STRING?t[r.value]?e.reportError(P(`Defer/Stream directive label argument must be unique.`,{nodes:[t[r.value],n]})):t[r.value]=n:e.reportError(P(`Directive "${n.name.value}"'s label argument must be a static string.`,{nodes:n}))}}}}function pp(e){return{Directive(t){let n=e.getSchema().getMutationType(),r=e.getSchema().getSubscriptionType(),i=e.getParentType();i&&t.name.value===Ps.name&&(n&&i===n&&e.reportError(P(`Defer directive cannot be used on root mutation type "${i.name}".`,{nodes:t})),r&&i===r&&e.reportError(P(`Defer directive cannot be used on root subscription type "${i.name}".`,{nodes:t}))),i&&t.name.value===Fs.name&&(n&&i===n&&e.reportError(P(`Stream directive cannot be used on root mutation type "${i.name}".`,{nodes:t})),r&&i===r&&e.reportError(P(`Stream directive cannot be used on root subscription type "${i.name}".`,{nodes:t})))}}}function mp(e,t){let n=0,r=0;for(;n<e.length&&r<t.length;){let i=e.charCodeAt(n),a=t.charCodeAt(r);if(gp(i)&&gp(a)){let o=0;do++n,o=o*10+i-hp,i=e.charCodeAt(n);while(gp(i)&&o>0);let s=0;do++r,s=s*10+a-hp,a=t.charCodeAt(r);while(gp(a)&&s>0);if(o<s)return-1;if(o>s)return 1}else{if(i<a)return-1;if(i>a)return 1;++n,++r}}return e.length-t.length}const hp=48;function gp(e){return!Number.isNaN(e)&&48<=e&&e<=57}function _p(e){switch(e.kind){case E.OBJECT:return{...e,fields:vp(e.fields)};case E.LIST:return{...e,values:e.values.map(_p)};case E.INT:case E.FLOAT:case E.STRING:case E.BOOLEAN:case E.NULL:case E.ENUM:case E.VARIABLE:return e}}function vp(e){return e.map(e=>({...e,value:_p(e.value)})).sort((e,t)=>mp(e.name.value,t.name.value))}function yp(e){return Array.isArray(e)?e.map(([e,t])=>`subfields "${e}" conflict because `+yp(t)).join(` and `):e}function bp(e){let t=new Ip,n=new Map;return{SelectionSet(r){let i=xp(e,n,t,e.getParentType(),r);for(let[[t,n],r,a]of i){let i=yp(n);e.reportError(P(`Fields "${t}" conflict because ${i}. Use different aliases on the fields to fetch both if this was intentional.`,{nodes:r.concat(a)}))}}}}function xp(e,t,n,r,i){let a=[],[o,s]=Mp(e,t,r,i);if(Tp(e,a,t,n,o),s.length!==0)for(let r=0;r<s.length;r++){Sp(e,a,t,n,!1,o,s[r]);for(let i=r+1;i<s.length;i++)Cp(e,a,t,n,!1,s[r],s[i])}return a}function Sp(e,t,n,r,i,a,o){let s=e.getFragment(o);if(!s)return;let[c,l]=Np(e,n,s);if(a!==c){Ep(e,t,n,r,i,a,c);for(let s of l)r.has(s,o,i)||(r.add(s,o,i),Sp(e,t,n,r,i,a,s))}}function Cp(e,t,n,r,i,a,o){if(a===o||r.has(a,o,i))return;r.add(a,o,i);let s=e.getFragment(a),c=e.getFragment(o);if(!s||!c)return;let[l,u]=Np(e,n,s),[d,f]=Np(e,n,c);Ep(e,t,n,r,i,l,d);for(let o of f)Cp(e,t,n,r,i,a,o);for(let a of u)Cp(e,t,n,r,i,a,o)}function wp(e,t,n,r,i,a,o,s){let c=[],[l,u]=Mp(e,t,i,a),[d,f]=Mp(e,t,o,s);Ep(e,c,t,n,r,l,d);for(let i of f)Sp(e,c,t,n,r,l,i);for(let i of u)Sp(e,c,t,n,r,d,i);for(let i of u)for(let a of f)Cp(e,c,t,n,r,i,a);return c}function Tp(e,t,n,r,i){for(let[a,o]of Object.entries(i))if(o.length>1)for(let i=0;i<o.length;i++)for(let s=i+1;s<o.length;s++){let c=Dp(e,n,r,!1,a,o[i],o[s]);c&&t.push(c)}}function Ep(e,t,n,r,i,a,o){for(let[s,c]of Object.entries(a)){let a=o[s];if(a)for(let o of c)for(let c of a){let a=Dp(e,n,r,i,s,o,c);a&&t.push(a)}}}function Dp(e,t,n,r,i,a,o){let[s,c,l]=a,[u,d,f]=o,p=r||s!==u&&j(s)&&j(u);if(!p){let e=c.name.value,t=d.name.value;if(e!==t)return[[i,`"${e}" and "${t}" are different fields`],[c],[d]];if(Op(c)!==Op(d))return[[i,`they have differing arguments`],[c],[d]]}if(!Ap(c.directives??[],d.directives??[]))return[[i,`they have differing stream directives`],[c],[d]];let m=l?.type,h=f?.type;if(m&&h&&jp(m,h))return[[i,`they return conflicting types "${Aa(m)}" and "${Aa(h)}"`],[c],[d]];let g=c.selectionSet,_=d.selectionSet;if(g&&_)return Fp(wp(e,t,n,p,Rt(m),g,Rt(h),_),i,c,d)}function Op(e){let t=e.arguments??[];return ft(_p({kind:E.OBJECT,fields:t.map(e=>({kind:E.OBJECT_FIELD,name:e.name,value:e.value}))}))}function kp(e){return e.find(e=>e.name.value===`stream`)}function Ap(e,t){let n=kp(e),r=kp(t);return!n&&!r?!0:n&&r?Op(n)===Op(r):!1}function jp(e,t){return Dt(e)?Dt(t)?jp(e.ofType,t.ofType):!0:Dt(t)?!0:M(e)?M(t)?jp(e.ofType,t.ofType):!0:M(t)?!0:At(e)||At(t)?e!==t:!1}function Mp(e,t,n,r){let i=t.get(r);if(i)return i;let a=Object.create(null),o=new Set;Pp(e,n,r,a,o);let s=[a,[...o]];return t.set(r,s),s}function Np(e,t,n){return t.get(n.selectionSet)||Mp(e,t,pr(e.getSchema(),n.typeCondition),n.selectionSet)}function Pp(e,t,n,r,i){for(let a of n.selections)switch(a.kind){case E.FIELD:{let e=a.name.value,n;(j(t)||Ct(t))&&(n=t.getFields()[e]);let i=a.alias?a.alias.value:e;r[i]||=[],r[i].push([t,a,n]);break}case E.FRAGMENT_SPREAD:i.add(a.name.value);break;case E.INLINE_FRAGMENT:{let n=a.typeCondition;Pp(e,n?pr(e.getSchema(),n):t,a.selectionSet,r,i);break}}}function Fp(e,t,n,r){if(e.length>0)return[[t,e.map(([e])=>e)],[n,...e.map(([,e])=>e).flat()],[r,...e.map(([,,e])=>e).flat()]]}var Ip=class{_data;constructor(){this._data=new Map}has(e,t,n){let[r,i]=e<t?[e,t]:[t,e],a=this._data.get(r)?.get(i);return a===void 0?!1:n?!0:n===a}add(e,t,n){let[r,i]=e<t?[e,t]:[t,e],a=this._data.get(r);a===void 0?this._data.set(r,new Map([[i,n]])):a.set(i,n)}};function Lp(e){return{Directive(t){let n=e.getFieldDef(),r=e.getParentType();n&&r&&t.name.value===Fs.name&&!(Dt(n.type)||Pt(n.type)&&Dt(n.type.ofType))&&e.reportError(P(`Stream directive cannot be used on non-list field "${n.name}" on type "${r.name}".`,{nodes:t}))}}}function Rp(){return{onSchemaChange:({schema:e,replaceSchema:t})=>{let n=[];e.getDirective(`defer`)??n.push(Ps),e.getDirective(`stream`)??n.push(Fs),n.length&&t(new Gn({...e.toConfig(),directives:[...e.getDirectives(),...n]}))},onValidate:({params:e,addValidationRule:t})=>{e.rules||=[],e.rules=e.rules.filter(e=>e.name!==`OverlappingFieldsCanBeMergedRule`),t(bp),t(fp),t(pp),t(Lp)}}}var zp=Object.defineProperty,Bp=(e,t)=>{let n={};for(var r in e)zp(n,r,{get:e[r],enumerable:!0});return t||zp(n,Symbol.toStringTag,{value:`Module`}),n},Vp=`__OSRA_KEY__`,Hp=`__OSRA_DEFAULT_KEY__`,Up=`__OSRA_BOX__`,Wp=()=>globalThis.browser??globalThis.chrome,Gp=()=>Wp()?.runtime,Kp=(e,t)=>dm(e)&&e.__OSRA_KEY__===t,qp=(e,t)=>{if(e){if(e.aborted){t();return}e.addEventListener(`abort`,t,{once:!0})}},Jp=({listener:e,transport:t,remoteName:n,key:r=Hp,origin:i=`*`,unregisterSignal:a})=>{if(a?.aborted)return;let o=km(t)?t.receive:t;if(typeof o==`function`){let t=o((t,i)=>{a?.aborted||Kp(t,r)&&(n&&t.name!==n||e(t,i))});typeof t==`function`&&qp(a,t);return}if(hm(o)||gm(o)||vm(o)||ym(o)){let t=(t,i)=>{let o=(t,a)=>{Kp(t,r)&&(n&&t.name!==n||e(t,{port:i,sender:a}))};t.addListener(o),qp(a,()=>t.removeListener(o))};if(hm(o))t(o.onMessage);else if(vm(o)){let e=e=>t(e.onMessage,e);o.addListener(e),qp(a,()=>o.removeListener(e))}else ym(o)?t(o):t(o.onMessage);return}let s=lm(o)?o.port:o,c=i!==`*`&&bm(o),l=t=>{let a=t.data;if(typeof a==`string`)try{a=JSON.parse(a)}catch{return}Kp(a,r)&&(n&&a.name!==n||c&&t.origin&&t.origin!==i||e(a,{receiveTransport:o,source:t.source,origin:t.origin}))};s.addEventListener(`message`,l),s instanceof MessagePort&&s.start(),qp(a,()=>s.removeEventListener(`message`,l))},Yp=new WeakSet,Xp=e=>String(e?.message??e).includes(`disconnected port`),Zp=(e,t,n=`*`,r=[])=>{let i=km(e)?e.emit:e;if(typeof i==`function`)i(t,r);else if(bm(i))i.postMessage(t,n,r);else if(gm(i)){if(Yp.has(i))return;try{i.postMessage(t)}catch(e){if(!Xp(e))throw e;Yp.add(i)}}else if(hm(i))i.sendMessage(t)?.catch?.(e=>{if(!String(e?.message).includes(`Receiving end does not exist`))throw e});else if(im(i)){let e=JSON.stringify(t);i.readyState===WebSocket.CONNECTING?i.addEventListener(`open`,()=>i.send(e),{once:!0}):i.send(e)}else lm(i)?i.port.postMessage(t,r):i.postMessage(t,r)},Qp=globalThis.Float16Array,$p={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float16Array:Qp,Float32Array,Float64Array,BigInt64Array,BigUint64Array},em=Object.values($p),tm=e=>{let t=e.constructor.name;if(t in $p)return t;for(let[t,n]of Object.entries($p))if(n&&e instanceof n)return t;throw Error(`Unknown typed array type`)},nm=e=>{let t=$p[e];if(!t)throw Error(`Unknown typed array type`);return t},rm=e=>fm(e,em),im=e=>e instanceof WebSocket,am=e=>!!globalThis.ServiceWorkerContainer&&e instanceof ServiceWorkerContainer,om=e=>!!globalThis.ServiceWorker&&e instanceof ServiceWorker,sm=e=>!!globalThis.Worker&&e instanceof Worker,cm=e=>{let t=globalThis.DedicatedWorkerGlobalScope;return!!t&&e instanceof t},lm=e=>!!globalThis.SharedWorker&&e instanceof SharedWorker,um=e=>e instanceof MessagePort,dm=e=>!!e&&typeof e==`object`&&`__OSRA_KEY__`in e&&!!e.__OSRA_KEY__,fm=(e,t)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return!1;for(let n of t)if(n&&e instanceof n)return!0;return!1},pm=e=>fm(e,[globalThis.SharedArrayBuffer]),mm=e=>fm(e,[globalThis.ArrayBuffer,globalThis.MessagePort,globalThis.ReadableStream,globalThis.WritableStream,globalThis.TransformStream,globalThis.ImageBitmap,globalThis.OffscreenCanvas,globalThis.AudioData,globalThis.VideoFrame,globalThis.MediaSourceHandle,globalThis.MediaStreamTrack,globalThis.MIDIAccess,globalThis.RTCDataChannel,globalThis.WebTransportReceiveStream,globalThis.WebTransportSendStream]),hm=e=>{let t=Gp();return t?e===t:!1},gm=(e,t=!1)=>!e||typeof e!=`object`||bm(e)||!(`name`in e)||!(`disconnect`in e)||!(`postMessage`in e)?!1:t?`sender`in e&&`onMessage`in e&&`onDisconnect`in e:!0,_m=e=>!!e&&typeof e==`object`&&!bm(e)&&`addListener`in e&&`hasListener`in e&&`removeListener`in e,vm=e=>{let t=Gp();return t?e===t.onConnect||e===t.onConnectExternal:!1},ym=e=>_m(e),bm=e=>{if(!e||typeof e!=`object`)return!1;try{return`window`in e&&e.window===e}catch{try{return`closed`in e&&typeof e.closed==`boolean`&&`close`in e&&typeof e.close==`function`}catch{return!1}}},xm=e=>im(e)||gm(e)||hm(e),Sm=e=>im(e)||gm(e)||vm(e)||ym(e)||hm(e),Cm=e=>!!e&&typeof e==`object`&&!bm(e)&&`isJson`in e&&e.isJson===!0||xm(e)||Sm(e),wm=e=>bm(e)||xm(e)||om(e)||sm(e)||cm(e)||lm(e)||um(e)||Dm(e),Tm=e=>bm(e)||Sm(e)||am(e)||sm(e)||cm(e)||lm(e)||um(e)||Om(e),Em=e=>{if(!e||typeof e!=`object`||bm(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Dm=e=>!Em(e)||!(`emit`in e)?!1:wm(e.emit)||typeof e.emit==`function`,Om=e=>!Em(e)||!(`receive`in e)?!1:Tm(e.receive)||typeof e.receive==`function`,km=e=>Dm(e)||Om(e),Am=()=>globalThis.Buffer,jm=32768,Mm=e=>{let t=e.toBase64;if(typeof t==`function`)return t.call(e);let n=Am();if(n)return n.from(e).toString(`base64`);let r=``;for(let t=0;t<e.length;t+=jm)r+=String.fromCharCode(...e.subarray(t,t+jm));return btoa(r)},Nm=e=>{let t=Uint8Array.fromBase64;if(typeof t==`function`)return t(e);let n=Am();if(n)return new Uint8Array(n.from(e,`base64`));let r=atob(e),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i},Pm={[Up]:`revivable`},Fm=e=>!!e&&typeof e==`object`&&`__OSRA_BOX__`in e&&e.__OSRA_BOX__===`revivable`,Im=(e,t)=>Cm(t.transport)?{base64Buffer:Mm(new Uint8Array(e))}:{arrayBuffer:e},Lm=e=>`arrayBuffer`in e?e.arrayBuffer:Nm(e.base64Buffer).buffer,Rm=Bp({box:()=>Vm,isType:()=>Bm,objectsOnly:()=>!0,revive:()=>Hm,type:()=>zm}),zm=`arrayBuffer`,Bm=e=>e instanceof ArrayBuffer,Vm=(e,t)=>({...Pm,type:zm,...Im(e,t)}),Hm=(e,t)=>Lm(e),Um=Bp({box:()=>Km,isType:()=>Gm,objectsOnly:()=>!0,revive:()=>qm,type:()=>Wm}),Wm=`date`,Gm=e=>e instanceof Date,Km=(e,t)=>({...Pm,type:Wm,ISOString:e.toISOString()}),qm=(e,t)=>new Date(e.ISOString),Jm=Bp({box:()=>Zm,isType:()=>Xm,objectsOnly:()=>!0,revive:()=>Qm,type:()=>Ym}),Ym=`headers`,Xm=e=>e instanceof Headers,Zm=(e,t)=>({...Pm,type:Ym,entries:[...e.entries()]}),Qm=(e,t)=>new Headers(e.entries),$m=Bp({box:()=>rh,isType:()=>nh,objectsOnly:()=>!0,revive:()=>ih,type:()=>eh}),eh=`error`,th={Error,TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError},nh=e=>e instanceof Error,rh=(e,t)=>{let n=`cause`in e&&e.cause!==void 0,r=typeof AggregateError<`u`&&e instanceof AggregateError,i=typeof DOMException<`u`&&e instanceof DOMException;return{...Pm,type:eh,name:e.name,message:e.message,stack:e.stack||e.toString(),...n?{cause:yv(e.cause,t)}:{},...r?{errors:yv(e.errors,t)}:{},...i?{isDOMException:!0}:{}}},ih=(e,t)=>{let n=e.cause===void 0?void 0:xv(e.cause,t),r=n===void 0?void 0:{cause:n};if(e.isDOMException&&typeof DOMException<`u`){let t=new DOMException(e.message,e.name);if(e.stack)try{Object.defineProperty(t,"stack",{value:e.stack,configurable:!0})}catch{}return t}let i;if(e.errors!==void 0&&typeof AggregateError<`u`)i=AggregateError(xv(e.errors,t),e.message,r);else{let t=th[e.name]??Error;i=r===void 0?new t(e.message):new t(e.message,r)}return e.name&&i.name!==e.name&&(i.name=e.name),e.stack&&(i.stack=e.stack),i},ah=Bp({box:()=>ch,isType:()=>sh,objectsOnly:()=>!0,revive:()=>lh,type:()=>oh}),oh=`typedArray`,sh=rm,ch=(e,t)=>{let n=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return{...Pm,type:oh,typedArrayType:tm(e),...Im(n,t)}},lh=(e,t)=>new(nm(e.typedArrayType))(Lm(e)),uh=new WeakMap,dh=new WeakSet,fh=(e,t)=>{if(dh.has(e))return t(),()=>{};let n=uh.get(e);return n||uh.set(e,n=new Set),n.add(t),()=>n.delete(t)},ph=e=>dh.has(e),mh=e=>{if(dh.has(e))return;dh.add(e);let t=uh.get(e);if(t){uh.delete(e);for(let e of t)try{e()}catch{}}},hh=Bp({box:()=>Dh,forceTransfer:()=>wh,isInTransfer:()=>Ch,isType:()=>Eh,objectsOnly:()=>!0,outsideTransfer:()=>Th,revive:()=>Oh,transfer:()=>xh,type:()=>gh}),gh=`transfer`,_h=Symbol.for(`osra.transfer`),vh=e=>typeof e==`object`&&!!e,yh=e=>vh(e)&&_h in e&&e[_h]===!0,bh=e=>vh(e)?ArrayBuffer.isView(e)?!0:fm(e,[globalThis.ArrayBuffer,globalThis.MessagePort,globalThis.ReadableStream,globalThis.WritableStream,globalThis.TransformStream,globalThis.Request,globalThis.Response,globalThis.ImageBitmap,globalThis.OffscreenCanvas,globalThis.VideoFrame,globalThis.AudioData]):!1,xh=e=>bh(e)?{[_h]:!0,value:e}:e,Sh=0,Ch=()=>Sh>0,wh=e=>vh(e)&&!yh(e)?{[_h]:!0,value:e}:e,Th=e=>{let t=Sh;Sh=0;try{return e()}finally{Sh=t}},Eh=e=>yh(e),Dh=(e,t)=>{Sh++;try{return{...Pm,type:gh,inner:yv(e.value,t),degraded:Cm(t.transport)}}finally{Sh--}},Oh=(e,t)=>xv(e.inner,t),kh=e=>fm(e,[globalThis.MessagePort,globalThis.ReadableStream,globalThis.WritableStream,globalThis.TransformStream,globalThis.OffscreenCanvas,globalThis.MediaSourceHandle,globalThis.MediaStreamTrack,globalThis.MIDIAccess,globalThis.RTCDataChannel,globalThis.WebTransportReceiveStream,globalThis.WebTransportSendStream]),Ah=e=>Fm(e)&&e.type===`transfer`,jh=e=>{let t=[],n=new WeakSet,r=(e,i)=>{if(!(!e||typeof e!=`object`)&&!n.has(e)&&(n.add(e),!pm(e))){if(Ah(e)){r(e.inner,i||!e.degraded);return}if(kh(e)){t.push(e);return}if(mm(e)){i&&t.push(e);return}if(ArrayBuffer.isView(e)){i&&e instanceof DataView&&!pm(e.buffer)&&!n.has(e.buffer)&&(n.add(e.buffer),t.push(e.buffer));return}if(Array.isArray(e)){for(let t of e)r(t,i);return}for(let t of Object.values(e))r(t,i)}};return r(e,!1),t},Mh=class{_listeners=new Map;addEventListener(e,t,n){if(!t)return;let r=this._listeners.get(e);r||(r=new Map,this._listeners.set(e,r)),r.has(t)||r.set(t,typeof n==`object`&&!!n?.once)}removeEventListener(e,t,n){t&&this._listeners.get(e)?.delete(t)}_peer;_queue=[];_started=!1;_closed=!1;_onClose;_onmessage=null;get onmessage(){return this._onmessage}set onmessage(e){this._onmessage=e,e!==null&&this.start()}onmessageerror=null;dispatchEvent(e){e.type===`message`?this._onmessage?.call(this,e):e.type===`messageerror`&&this.onmessageerror?.call(this,e);let t=this._listeners.get(e.type);if(t)for(let[n,r]of[...t])r&&t.delete(n),typeof n==`function`?n.call(this,e):n.handleEvent(e);return!0}postMessage(e,t){let n=this._peer;!n||n._closed||queueMicrotask(()=>{if(n._closed)return;let t=new MessageEvent(`message`,{data:e});n._started?n.dispatchEvent(t):n._queue.push(t)})}start(){if(!this._started){this._started=!0;for(let e of this._queue.splice(0))this.dispatchEvent(e)}}close(){if(this._closed)return;this._closed=!0,this._queue.length=0,this._onClose?.();let e=this._peer;e&&!e._closed&&queueMicrotask(()=>{e._closed||e.dispatchEvent(new Event(`close`))})}},Nh=class{port1;port2;constructor(){let e=new Mh,t=new Mh;e._peer=t,t._peer=e,this.port1=e,this.port2=t}},Ph=new FinalizationRegistry(e=>{try{e()}catch{}}),Fh=(e,t)=>{let n={};return Ph.register(e,t,n),()=>Ph.unregister(n)},Ih=Bp({box:()=>ig,createRevivableChannel:()=>lg,init:()=>Jh,isType:()=>Yh,markPortsShipped:()=>sg,objectsOnly:()=>!0,postPreBoxed:()=>ng,revive:()=>ag,type:()=>Lh}),Lh=`messagePort`,Rh=2048,zh=128,Bh=1024,Vh=new WeakMap,Hh=e=>{let t=Vh.get(e);if(!t)throw Error(`osra message-port: connection state missing; did init() run?`);return t},Uh=(e,t)=>{let n=e.ports.get(t);return n||(n={nextSeq:0,buffer:new Map,outSeq:0},e.ports.set(t,n),e.pendingPorts++),n},Wh=(e,t)=>{let n=e.ports.get(t);if(n&&!n.handler&&e.pendingPorts--,e.ports.delete(t),e.tombstones.size>=zh){let t=e.tombstones.values().next().value;t!==void 0&&e.tombstones.delete(t)}e.tombstones.add(t)},Gh=e=>{if(e.handler)for(let t=e.buffer.get(e.nextSeq);t!==void 0;t=e.buffer.get(e.nextSeq))e.buffer.delete(e.nextSeq),e.nextSeq++,e.handler(t)},Kh=(e,t)=>Uh(Hh(e),t).outSeq++,qh=(e,t,n)=>{let r=Hh(e);if(r.tombstones.has(t)){setTimeout(()=>n({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:t}));return}let i=Uh(r,t);i.handler||r.pendingPorts--,i.handler=n,Gh(i)},Jh=e=>{let t={ports:new Map,tombstones:new Set,pendingPorts:0};Vh.set(e,t),e.eventTarget.addEventListener(`message`,({detail:n})=>{if(n.type!==`message`&&n.type!==`message-port-close`||t.tombstones.has(n.portId))return;let r=t.ports.get(n.portId);if(n.seq===void 0){r?.handler?.(n);return}if(!r){if(t.pendingPorts>=Bh)return;r=Uh(t,n.portId)}if(!(n.seq<r.nextSeq)){if(r.buffer.size>=Rh&&!(n.seq===r.nextSeq&&r.handler)){r.buffer.clear(),Wh(t,n.portId),r.handler?.({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:n.portId});return}r.buffer.set(n.seq,n),Gh(r)}}),fh(e,()=>{for(let[n,r]of[...t.ports])r.handler?.({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:n});t.ports.clear(),t.tombstones.clear(),t.pendingPorts=0})},Yh=e=>e instanceof MessagePort||e instanceof Mh,Xh=(e,t)=>{try{let n=Hh(e).ports.get(t);e.sendMessage({type:`message-port-close`,remoteUuid:e.remoteUuid,portId:t,seq:n?n.outSeq++:0})}catch{}},Zh=(e,t,n)=>{if(n){e.postMessage(t);return}let r=jh(t);e.postMessage(t,r),sg(r)},Qh=(e,t,n,r)=>{let i;try{i=xv(e,t)}catch(e){r(),globalThis.reportError?.(e);return}n(i)},$h=(e,t,n)=>()=>{let r=e.deref();r&&Xh(r,n);let i=t.deref();i&&Wh(i,n)},eg=new WeakSet,tg=e=>e!==null&&(typeof e==`object`||typeof e==`function`),ng=(e,t,n)=>{tg(t)&&eg.add(t),e.postMessage(t,n??[])},rg=(e,t)=>tg(e)&&eg.delete(e)?e:Th(()=>yv(e,t)),ig=(e,t,n)=>{let r=e instanceof Mh;if(!r&&!Cm(t.transport))return{...Pm,type:Lh,port:e,...n?.autoBox?{autoBox:!0}:{}};let i=Hh(t),a=e,o=globalThis.crypto.randomUUID(),s=new WeakRef(a),c=new WeakRef(t),l=new WeakRef(i),u=!1,d=()=>{if(u)return;u=!0;let e=l.deref();e&&Wh(e,o),m?.();let t=s.deref();t?.removeEventListener(`message`,p),t instanceof Mh&&(t._onClose=void 0)},f=e=>{if(e.type===`message-port-close`){d(),a.dispatchEvent(new Event(`close`)),a.close();return}Qh(e.data,t,e=>Zh(a,e,!1),()=>{})};function p({data:e}){t.sendMessage({type:`message`,remoteUuid:t.remoteUuid,data:rg(e,t),portId:o,seq:Kh(t,o)})}let m=Fh(a,$h(c,l,o));return a.addEventListener(`message`,p),a.start(),a instanceof Mh&&(a._onClose=()=>{u||(Xh(t,o),d())}),qh(t,o,f),{...Pm,type:Lh,portId:o,synthetic:r}},ag=(e,t)=>`port`in e?(sg([e.port]),e.autoBox?cg(e.port,t):e.port):ug(e.portId,t,e.synthetic),og=new WeakMap,sg=e=>{for(let t of e){let e=og.get(t);if(e){og.delete(t),e.shipped=!0;for(let t of e.pending.splice(0))t()}}},cg=(e,t,n)=>{let r=new EventTarget,i=({data:e})=>{Qh(e,t,e=>r.dispatchEvent(new MessageEvent(`message`,{data:e})),()=>r.dispatchEvent(new Event(`messageerror`)))},a=()=>{r.dispatchEvent(new Event(`messageerror`))},o=()=>{r.dispatchEvent(new Event(`close`))};e.addEventListener(`message`,i),e.addEventListener(`messageerror`,a),e.addEventListener(`close`,o),r.postMessage=(r,i)=>{let a=Th(()=>yv(r,t)),o=jh(a),s=Array.isArray(i)?i:[],c=s.length?[...o,...s]:o,l=()=>{e.postMessage(a,c),sg(c)};if(n&&!n.shipped){n.pending.push(l);return}l()},r.start=()=>e.start();let s=()=>{e.removeEventListener(`message`,i),e.removeEventListener(`messageerror`,a),e.removeEventListener(`close`,o),e.close()};return r.close=()=>{if(n&&!n.shipped){n.pending.push(s);return}s()},r},lg=e=>{if(Cm(e.transport)){let{port1:t,port2:n}=new Nh;return{localPort:t,boxedRemote:ig(n,e)}}let{port1:t,port2:n}=new MessageChannel,r={shipped:!1,pending:[]};return og.set(n,r),{localPort:cg(t,e,r),boxedRemote:ig(n,e,{autoBox:!0})}},ug=(e,t,n)=>{let r=Hh(t),{port1:i,port2:a}=n?new Nh:new MessageChannel,o=new WeakRef(i),s=new WeakRef(a),c=!1,l=!1;i instanceof Mh||i.addEventListener(`close`,e=>{l&&e.stopImmediatePropagation()});let u=()=>{if(c)return;c=!0,Wh(r,e);let t=s.deref();t?.removeEventListener(`message`,f),t?.close(),p?.()},d=e=>{if(e.type===`message-port-close`){u();let e=o.deref();e?.dispatchEvent(new Event(`close`)),l=!0,e?.close();return}if(!o.deref()){u();return}let r=s.deref();r&&Qh(e.data,t,e=>Zh(r,e,n),()=>o.deref()?.dispatchEvent(new Event(`messageerror`)))},f=({data:n})=>{t.sendMessage({type:`message`,remoteUuid:t.remoteUuid,data:rg(n,t),portId:e,seq:Kh(t,e)})},p=Fh(i,()=>{Xh(t,e),u()});return i instanceof Mh&&(i._onClose=()=>{c||(Xh(t,e),u())}),a.addEventListener(`message`,f),a.start(),qh(t,e,d),i},dg=Bp({box:()=>gg,isType:()=>hg,objectsOnly:()=>!0,revive:()=>_g,type:()=>fg}),fg=`promise`,pg=e=>e instanceof Promise,mg=new Set,hg=e=>e instanceof Promise,gg=(e,t)=>{if(!pg(e))throw TypeError(`Expected Promise`);let{localPort:n,boxedRemote:r}=lg(t),i=e=>{n.postMessage(e),n.close()};return e.then(e=>i({type:`resolve`,data:e})).catch(e=>i({type:`reject`,error:e})),{...Pm,type:fg,port:r}},_g=(e,t)=>{let n=ag(e.port,t);mg.add(n);let r=`portId`in e.port;return new Promise((e,i)=>{let a,o=()=>{n.close(),mg.delete(n),a?.()};if(r&&ph(t)){i(Error(`osra: connection closed`)),o();return}a=r?fh(t,()=>{i(Error(`osra: connection closed`)),o()}):void 0,n.addEventListener(`message`,({data:t})=>{t.type===`resolve`?e(t.data):i(t.error),o()},{once:!0}),n.start()})},vg=Bp({box:()=>Cg,isType:()=>Sg,objectsOnly:()=>!0,revive:()=>wg,type:()=>yg}),yg=`function`,bg=new Set,xg=e=>{e instanceof ReadableStream?e.locked||e.cancel(Error(`osra: connection closed`)).catch(()=>{}):typeof WritableStream<`u`&&e instanceof WritableStream&&(e.locked||e.abort(Error(`osra: connection closed`)).catch(()=>{}))},Sg=e=>typeof e==`function`,Cg=(e,t)=>{let{port1:n,port2:r}=new Nh;return n.addEventListener(`message`,({data:n})=>{let[r,i]=n;(async()=>{let n;try{n={type:`return`,value:await e(...i)}}catch(e){n={type:`throw`,error:e}}if(ph(t)){n.type===`return`&&xg(n.value);try{r.close()}catch{}return}let a=(()=>{try{return yv(n,t)}catch(e){return yv({type:`throw`,error:e},t)}})();ng(r,a),queueMicrotask(()=>{try{r.close()}catch{}})})()}),n.start(),{...Pm,type:yg,port:ig(r,t)}},wg=(e,t)=>{let n=ag(e.port,t);return((...e)=>new Promise((r,i)=>{if(ph(t)){i(Error(`osra: connection closed`));return}let{port1:a,port2:o}=new Nh;bg.add(a);let s,c=()=>{a.close(),bg.delete(a),s?.()};s=fh(t,()=>{i(Error(`osra: connection closed`)),c()}),a.addEventListener(`message`,({data:e})=>{let t=e;t.type===`return`?r(t.value):i(t.error),c()},{once:!0}),a.start();let l=Th(()=>yv([o,e],t));ng(n,l)}))},Tg=Bp({MAX_CREDIT_WINDOW:()=>64,box:()=>jg,isType:()=>Dg,objectsOnly:()=>!0,revive:()=>Fg,type:()=>Eg}),Eg=`readableStream`,Dg=e=>e instanceof ReadableStream,Og=2,kg=8,Ag=4*1024*1024,jg=(e,t)=>{let{localPort:n,boxedRemote:r}=lg(t),i=e.getReader(),a=Ch(),o=0,s=!1,c=!1,l=e=>{c=!0;try{n.postMessage(e)}catch{}n.close()},u=async()=>{if(!(s||c)){for(s=!0;o>0;){let e;try{e=await i.read()}catch(e){c||l({type:`error`,error:e});return}if(c)return;if(e.done){l({type:`end`});return}o--;let t=a?wh(e.value):e.value;try{n.postMessage({type:`chunk`,value:t})}catch(e){l({type:`error`,error:e}),i.cancel(e).catch(()=>{});return}}s=!1}};return n.addEventListener(`message`,({data:e})=>{e instanceof Promise||!(`type`in e)||(e.type===`pull`?n.postMessage(i.read()):e.type===`credit`?(o+=e.n,u()):e.type===`cancel`&&(c=!0,i.cancel(e.reason).catch(()=>{}),n.close()))}),n.addEventListener(`close`,()=>{c||(c=!0,i.cancel(Error(`osra: connection closed`)).catch(()=>{}))},{once:!0}),n.start(),{...Pm,type:Eg,credit:!0,port:r}},Mg=e=>ArrayBuffer.isView(e)||e instanceof ArrayBuffer?e.byteLength:typeof e==`string`?e.length*2:typeof Blob<`u`&&e instanceof Blob?e.size:void 0,Ng=e=>{let t=!1,n=0,r,i=[],a=!1,o=!1,s,c,l=()=>r===void 0?kg:Math.max(Og,Math.min(64,Math.floor(Ag/r))),u=()=>{let t=l(),r=n+i.length;if(r>t/2)return;let a=t-r;n+=a,e.postMessage({type:`credit`,n:a})},d=()=>{t=!0,queueMicrotask(()=>e.close())},f=e=>{if(o=!0,s=e,!c||i.length)return;let t=c;c=void 0,d(),t.reject(e)};return new ReadableStream({start:()=>{e.addEventListener(`message`,({data:o})=>{if(!(o instanceof Promise||!(`type`in o))){if(o.type===`chunk`){if(t)return;if(n<=0){i.length=0,f(Error(`osra: stream exceeded its credit window`)),queueMicrotask(()=>e.close());return}n--;let a=Mg(o.value);if(a!==void 0&&(r=r===void 0?a:r*.875+a*.125),c){let e=c;c=void 0,e.controller.enqueue(o.value),e.resolve()}else i.push(o.value)}else if(o.type===`end`){if(t||(a=!0,!c||i.length))return;let e=c;c=void 0,d(),e.controller.close(),e.resolve()}else if(o.type===`error`){if(t)return;f(o.error)}}}),e.addEventListener(`messageerror`,()=>{t||f(Error(`osra: a chunk failed to deserialize on this platform`))}),e.addEventListener(`close`,()=>{t||a||o||f(Error(`osra: connection closed`))},{once:!0})},pull:e=>{if(!t){if(i.length){e.enqueue(i.shift()),!a&&!o&&u();return}if(o)return d(),Promise.reject(s);if(a){d(),e.close();return}return u(),new Promise((t,n)=>{c={controller:e,resolve:t,reject:n}})}},cancel:n=>{t=!0,i.length=0;let r=c;c=void 0,r?.resolve(),e.postMessage({type:`cancel`,reason:n}),queueMicrotask(()=>e.close())}})},Pg=e=>{let t=!1;return new ReadableStream({start:n=>{e.addEventListener(`messageerror`,()=>{if(!t){t=!0;try{n.error(Error(`osra: a chunk failed to deserialize on this platform`))}catch{}queueMicrotask(()=>e.close())}}),e.addEventListener(`close`,()=>{if(!t){t=!0;try{n.error(Error(`osra: connection closed`))}catch{}}},{once:!0})},pull:n=>new Promise((r,i)=>{e.addEventListener(`message`,({data:a})=>{a instanceof Promise&&a.then(i=>{i.done?(t=!0,n.close(),e.postMessage({type:`cancel`}),queueMicrotask(()=>e.close())):n.enqueue(i.value),r()}).catch(e=>{t=!0,i(e)})},{once:!0}),e.postMessage({type:`pull`})}),cancel:n=>{t=!0,e.postMessage({type:`cancel`,reason:n}),queueMicrotask(()=>e.close())}})},Fg=(e,t)=>{let n=ag(e.port,t);return n.start(),e.credit?Ng(n):Pg(n)},Ig=Bp({box:()=>zg,isType:()=>Rg,objectsOnly:()=>!0,revive:()=>Bg,type:()=>Lg}),Lg=`writableStream`,Rg=e=>e instanceof WritableStream,zg=(e,t)=>{let{localPort:n,boxedRemote:r}=lg(t),i=e.getWriter(),a=!1,o=(e,t)=>e.then(()=>n.postMessage({type:`ack`})).catch(e=>n.postMessage({type:`err`,error:e?.message??String(e)})).then(()=>{t&&(a=!0,queueMicrotask(()=>n.close()))});return n.addEventListener(`message`,({data:e})=>{!e||typeof e!=`object`||!(`type`in e)||(e.type===`write`?o(i.write(e.chunk),!1):e.type===`close`?o(i.close(),!0):e.type===`abort`&&o(i.abort(e.reason),!0))}),n.addEventListener(`messageerror`,()=>{n.postMessage({type:`err`,error:`osra: a chunk failed to deserialize on this platform`})}),n.addEventListener(`close`,()=>{a||(a=!0,i.abort(Error(`osra: connection closed`)).catch(()=>{}))},{once:!0}),n.start(),{...Pm,type:Lg,port:r,...Ch()?{transferChunks:!0}:{}}},Bg=(e,t)=>{let n=ag(e.port,t);n.start();let r=new Set,i=!1;n.addEventListener(`close`,()=>{i=!0;let e=Error(`osra: connection closed`);for(let t of[...r])t(e);r.clear()},{once:!0});let a=Promise.resolve(),o=e=>{let t=a.then(()=>new Promise((t,a)=>{if(i){a(Error(`osra: connection closed`));return}let o=e=>{r.delete(a),e()};r.add(a),n.addEventListener(`message`,({data:e})=>{!e||typeof e!=`object`||!(`type`in e)||(e.type===`ack`?o(t):e.type===`err`&&o(()=>a(Error(e.error))))},{once:!0}),n.postMessage(e)}));return a=t.catch(()=>{}),t},s=e.transferChunks===!0;return new WritableStream({write:e=>o({type:`write`,chunk:s?wh(e):e}),close:()=>o({type:`close`}),abort:e=>o({type:`abort`,reason:e})})},Vg=Bp({box:()=>Gg,isType:()=>Ug,objectsOnly:()=>!0,revive:()=>Kg,type:()=>Hg}),Hg=`abortSignal`,Ug=e=>e instanceof AbortSignal,Wg=new WeakMap,Gg=(e,t)=>{if(e.aborted)return{...Pm,type:Hg,aborted:!0,reason:yv(e.reason,t)};let{localPort:n,boxedRemote:r}=lg(t),i=()=>{n.postMessage({type:`abort`,reason:e.reason}),n.close(),a()},a=fh(t,()=>{e.removeEventListener(`abort`,i),n.close()});return e.addEventListener(`abort`,i,{once:!0}),{...Pm,type:Hg,aborted:!1,reason:void 0,port:r}},Kg=(e,t)=>{let n=new AbortController;if(e.aborted||e.port===void 0)return n.abort(xv(e.reason,t)),n.signal;let r=ag(e.port,t);return Wg.set(n.signal,r),r.start(),r.addEventListener(`message`,({data:e})=>{e.type===`abort`&&(n.abort(xv(e.reason,t)),Wg.delete(n.signal),r.close())}),n.signal},qg=Bp({box:()=>Xg,isType:()=>Yg,objectsOnly:()=>!0,revive:()=>Zg,type:()=>Jg}),Jg=`response`,Yg=e=>e instanceof Response,Xg=(e,t)=>({...Pm,type:Jg,status:e.status,statusText:e.statusText,headers:Zm(e.headers,t),body:e.body?jg(e.body,t):null,url:e.url,redirected:e.redirected}),Zg=(e,t)=>{if(e.status===0)return Response.error();let n=Qm(e.headers,t),r=e.body?Fg(e.body,t):null,i=e.status===101||e.status===204||e.status===205||e.status===304;r&&i&&r.cancel().catch(()=>{});let a=new Response(i?null:r,{status:e.status,statusText:e.statusText,headers:n});return e.url&&Object.defineProperty(a,"url",{value:e.url,configurable:!0}),e.redirected&&Object.defineProperty(a,"redirected",{value:!0,configurable:!0}),a},tee=Bp({box:()=>ree,isType:()=>nee,objectsOnly:()=>!0,revive:()=>$g,type:()=>Qg}),Qg=`request`,nee=e=>e instanceof Request,ree=(e,t)=>({...Pm,type:Qg,method:e.method,url:e.url,headers:Zm(e.headers,t),body:e.body?jg(e.body,t):null,credentials:e.credentials,cache:e.cache,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,integrity:e.integrity,keepalive:e.keepalive,signal:Gg(e.signal,t)}),$g=(e,t)=>{let n=Qm(e.headers,t),r={method:e.method,headers:n,credentials:e.credentials,cache:e.cache,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy,integrity:e.integrity,keepalive:e.keepalive,signal:Kg(e.signal,t)};return e.mode!==`navigate`&&(r.mode=e.mode),e.body&&(r.body=Fg(e.body,t),r.duplex=`half`),new Request(e.url,r)},e_=Bp({box:()=>f_,boxByReference:()=>p_,identity:()=>o_,isType:()=>l_,objectsOnly:()=>!0,revive:()=>m_,type:()=>t_}),t_=`identity`,n_=e=>e!==null&&(typeof e==`object`||typeof e==`function`),r_=e=>{if(e===null)return!1;let t=typeof e;return t===`object`||t===`function`?!0:t===`symbol`?Symbol.keyFor(e)===void 0:!1},i_=new WeakMap,a_=e=>{let t=i_.get(e);if(t!==void 0)return t;let n=globalThis.crypto.randomUUID();return i_.set(e,n),n},o_=e=>(n_(e)&&a_(e),e),s_=new WeakMap,c_=e=>{let t=s_.get(e);if(t)return t;let n=new Map,r={idToLocal:n,pins:new Map,aliasIds:new WeakMap,disposeRegistry:new FinalizationRegistry(t=>{if(n.delete(t),!ph(e))try{e.sendMessage({type:`identity-dispose`,remoteUuid:e.remoteUuid,id:t})}catch{}})};return s_.set(e,r),e.eventTarget.addEventListener(`message`,({detail:e})=>{e?.type===`identity-dispose`&&(r.pins.delete(e.id),r.idToLocal.delete(e.id))}),fh(e,()=>{r.pins.clear(),r.idToLocal.clear()}),r},l_=e=>n_(e)&&i_.has(e),u_=(e,t)=>{let n=t.aliasIds.get(e);if(n!==void 0)return n;let r=a_(e),i=t.idToLocal.get(r);if(i===void 0||i.deref()===e)return r;let a=globalThis.crypto.randomUUID();return t.aliasIds.set(e,a),a},d_=(e,t,n)=>{let r=u_(e,n);if(n.idToLocal.has(r))return{...Pm,type:t_,id:r};let i=t();return n.idToLocal.set(r,new WeakRef(e)),n.disposeRegistry.register(e,r,e),pv(()=>{},()=>{n.idToLocal.delete(r),n.disposeRegistry.unregister(e)}),{...Pm,type:t_,id:r,inner:i}},f_=(e,t)=>{let n=c_(t),r=()=>bv(e,t,t_);return r_(e)?d_(e,r,n):{...Pm,type:t_,id:globalThis.crypto.randomUUID(),inner:r()}},p_=(e,t,n)=>d_(e,()=>t,c_(n)),m_=(e,t)=>{let n=c_(t);if(n.pins.has(e.id))return n.pins.get(e.id);let r=n.idToLocal.get(e.id)?.deref();if(r!==void 0)return r;if(!(`inner`in e)||e.inner===void 0){try{t.sendMessage({type:`identity-dispose`,remoteUuid:t.remoteUuid,id:e.id})}catch{}throw Error(`osra identity: received id=${e.id} with no inner payload and nothing local to resolve it to`)}let i=xv(e.inner,t);return n.pins.set(e.id,i),r_(i)&&(i_.has(i)||i_.set(i,e.id),n.idToLocal.set(e.id,new WeakRef(i))),i},h_=Bp({box:()=>__,isType:()=>g_,objectsOnly:()=>!0,revive:()=>v_,type:()=>`map`}),g_=e=>e instanceof Map,__=(e,t)=>({...Pm,type:`map`,entries:Array.from(e,([e,n])=>[yv(e,t),yv(n,t)])}),v_=(e,t)=>new Map(e.entries.map(([e,n])=>[xv(e,t),xv(n,t)])),y_=Bp({box:()=>x_,isType:()=>b_,objectsOnly:()=>!0,revive:()=>S_,type:()=>`set`}),b_=e=>e instanceof Set,x_=(e,t)=>({...Pm,type:`set`,values:Array.from(e,e=>yv(e,t))}),S_=(e,t)=>new Set(e.values.map(e=>xv(e,t))),C_=Bp({box:()=>E_,isType:()=>T_,revive:()=>D_,type:()=>w_}),w_=`bigint`,T_=e=>typeof e==`bigint`,E_=(e,t)=>({...Pm,type:w_,value:e.toString()}),D_=(e,t)=>BigInt(e.value),O_=Bp({box:()=>j_,isType:()=>A_,objectsOnly:()=>!0,revive:()=>M_,type:()=>k_}),k_=`event`,A_=e=>e instanceof Event,j_=(e,t)=>({...Pm,type:k_,eventType:e.type,bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed,...e instanceof CustomEvent?{detail:yv(e.detail,t)}:{}}),M_=(e,t)=>{let n={bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed};return`detail`in e?new CustomEvent(e.eventType,{...n,detail:xv(e.detail,t)}):new Event(e.eventType,n)},N_=Bp({box:()=>I_,isType:()=>F_,objectsOnly:()=>!0,revive:()=>B_,type:()=>P_}),P_=`eventTarget`,F_=e=>e instanceof EventTarget,I_=(e,t)=>{let n=[],r=e=>typeof e==`boolean`?e:!!e?.capture;return{...Pm,type:P_,addListener:Cg((t,i,a)=>{n.push({eventType:t,listener:i,capture:r(a)}),e.addEventListener(t,i,a)},t),removeListener:Cg((t,i,a)=>{let o=r(a),s=n.findIndex(e=>e.eventType===t&&e.listener===i&&e.capture===o);s!==-1&&n.splice(s,1),e.removeEventListener(t,i,a)},t),removeAllListeners:Cg(()=>{for(let{eventType:t,listener:r,capture:i}of n.splice(0))e.removeEventListener(t,r,{capture:i})},t)}},L_=new WeakMap,R_=e=>{if(typeof e==`function`)return e;let t=L_.get(e);return t||L_.set(e,t=t=>e.handleEvent(t)),t},z_=(e,t,n,r)=>e.find(e=>e.eventType===t&&e.listener===n&&e.capture===r),B_=(e,t)=>{let n=wg(e.addListener,t),r=wg(e.removeListener,t),i=wg(e.removeAllListeners,t),a=new EventTarget,o=[],s=e=>{let t=o.indexOf(e);t!==-1&&o.splice(t,1)};return Object.defineProperty(a,"addEventListener",{value:(e,t,r)=>{if(t===null)return;let i=R_(t),a=typeof r==`boolean`?r:!!r?.capture;if(z_(o,e,i,a))return;let c=typeof r==`object`&&r?.once?e=>(s(l),i(e)):i,l={eventType:e,listener:i,capture:a,wire:c};o.push(l),(typeof r==`object`?r?.signal:void 0)?.addEventListener(`abort`,()=>s(l),{once:!0}),n(e,o_(c),r).catch(()=>{})}}),Object.defineProperty(a,"removeEventListener",{value:(e,t,n)=>{if(t===null)return;let i=R_(t),a=typeof n==`boolean`?n:!!n?.capture,c=z_(o,e,i,a);c&&(s(c),r(e,o_(c.wire),{capture:a}).catch(()=>{}))}}),Fh(a,()=>{i().catch(()=>{})}),a},V_=Bp({box:()=>W_,isType:()=>U_,revive:()=>G_,type:()=>H_}),H_=`symbol`,U_=e=>typeof e==`symbol`,W_=(e,t)=>{let n=Symbol.keyFor(e);return n===void 0?p_(e,{...Pm,type:H_,description:e.description},t):{...Pm,type:H_,registryKey:n}},G_=(e,t)=>`registryKey`in e?Symbol.for(e.registryKey):Symbol(e.description),K_=Bp({box:()=>Y_,isType:()=>J_,objectsOnly:()=>!0,revive:()=>X_,type:()=>q_}),q_=`asyncIterator`,J_=e=>!e||typeof e!=`object`||typeof ReadableStream<`u`&&e instanceof ReadableStream?!1:typeof e[Symbol.asyncIterator]==`function`,Y_=(e,t)=>{let n=e[Symbol.asyncIterator]();return{...Pm,type:q_,next:Cg((e=>n.next(e)),t),return:Cg((e=>n.return?.(e)??Promise.resolve({done:!0,value:e})),t),throw:Cg((e=>n.throw?.(e)??Promise.reject(e)),t)}},X_=(e,t)=>{let n=wg(e.next,t),r=wg(e.return,t),i=wg(e.throw,t),a={next:(...e)=>n(...e),return:e=>r(e),throw:e=>i(e),[Symbol.asyncIterator]:()=>a};return a},Z_=[globalThis.File,globalThis.FileList,globalThis.RegExp,globalThis.DataView,globalThis.ImageData,globalThis.FormData,globalThis.DOMException,globalThis.DOMMatrix,globalThis.DOMMatrixReadOnly,globalThis.DOMPoint,globalThis.DOMPointReadOnly,globalThis.DOMQuad,globalThis.DOMRect,globalThis.DOMRectReadOnly,globalThis.CryptoKey,globalThis.FileSystemHandle,globalThis.FileSystemFileHandle,globalThis.FileSystemDirectoryHandle,globalThis.RTCCertificate],Q_=[globalThis.CropTarget,globalThis.EncodedAudioChunk,globalThis.EncodedVideoChunk,globalThis.FencedFrameConfig,globalThis.GPUCompilationInfo,globalThis.GPUCompilationMessage,globalThis.GPUPipelineError,globalThis.RTCEncodedAudioFrame,globalThis.RTCEncodedVideoFrame,globalThis.WebTransportError],$_={type:`clonable`,capableOnly:!0,objectsOnly:!0,isType:e=>fm(e,Z_)||fm(e,Q_),box:(e,t)=>e,revive:(e,t)=>e},ev=[globalThis.ImageBitmap,globalThis.OffscreenCanvas,globalThis.WritableStream,globalThis.TransformStream,globalThis.MediaStreamTrack,globalThis.RTCDataChannel],tv=[globalThis.AudioData,globalThis.VideoFrame,globalThis.MediaSourceHandle,globalThis.MIDIAccess,globalThis.WebTransportReceiveStream,globalThis.WebTransportSendStream],nv={type:`transferable`,capableOnly:!0,objectsOnly:!0,isType:e=>fm(e,ev)||fm(e,tv),box:(e,t)=>e,revive:(e,t)=>e},rv={type:`blob`,capableOnly:!0,objectsOnly:!0,isType:e=>typeof Blob<`u`&&e instanceof Blob,box:(e,t)=>{if(Cm(t.transport))throw TypeError(`osra: Blob is only supported on structured-clone transports, send an ArrayBuffer or Uint8Array instead`);return e},revive:(e,t)=>e},iv=e=>{if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},av=[hh,e_,Rm,Um,Jm,$m,ah,dg,vg,Ih,Tg,Ig,Vg,qg,tee,h_,y_,C_,V_,O_,K_,{type:`nonFiniteNumber`,isType:e=>typeof e==`number`&&!Number.isFinite(e),box:(e,t)=>Cm(t.transport)?{...Pm,type:`nonFiniteNumber`,value:String(e)}:e,revive:(e,t)=>Number(e.value)},{type:`undefined`,isType:e=>e===void 0,box:(e,t)=>Cm(t.transport)?{...Pm,type:`undefined`}:e,revive:(e,t)=>void 0},$_,nv,rv,N_,{type:`unclonable`,objectsOnly:!0,isType:e=>{if(typeof e!=`object`||!e||Array.isArray(e)||iv(e))return!1;try{return structuredClone(e),!1}catch{return!0}},box:(e,t)=>({...Pm,type:`unclonable`}),revive:(e,t)=>({})}],ov=(e,t)=>t.find(t=>t.type===e.type),sv=e=>!!e&&typeof e==`object`&&Object.getPrototypeOf(e)===Object.prototype,cv=(e,t)=>Array.isArray(e)?e.map(e=>t(e)):sv(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)])):e,lv=new WeakSet,uv=new WeakSet,dv=0,fv=[],pv=(e,t)=>{if(dv===0){e();return}fv.push({commit:e,rollback:t})},mv=e=>{let t=fv;fv=[];for(let n of t)try{e?n.rollback():n.commit()}catch{}},hv=e=>e!==null&&(typeof e==`object`||typeof e==`function`),gv=new WeakMap,_v=e=>{let t=gv.get(e);if(t)return t;let n=e.filter(e=>!e.objectsOnly);return gv.set(e,n),n},vv=(e,t,n)=>{let r=(e===null||typeof e!=`object`&&typeof e!=`function`?_v(t.revivableModules):t.revivableModules).find(t=>t.type!==n&&t.isType(e));return r?r.box(e,t):cv(e,e=>yv(e,t))},yv=(e,t)=>{if(Fm(e))return e;let n=hv(e);if(n){if(lv.has(e))throw TypeError(`osra: cannot serialize a circular structure - break the cycle or send the container by reference`);lv.add(e)}dv++;let r=!0;try{let n=vv(e,t);return r=!1,n}finally{n&&lv.delete(e),dv--,dv===0&&mv(r)}},bv=(e,t,n)=>vv(e,t,n),xv=(e,t)=>{let n=hv(e);if(n){if(uv.has(e))throw TypeError(`osra: cannot revive a circular structure`);uv.add(e)}try{if(Fm(e)){let n=ov(e,t.revivableModules);if(n)return n.revive(e,t)}return cv(e,e=>xv(e,t))}finally{n&&uv.delete(e)}},Sv=Bp({init:()=>Tv,startBidirectionalConnection:()=>wv,type:()=>Cv}),Cv=`bidirectional`,wv=({transport:e,value:t,remoteUuid:n,eventTarget:r,send:i,revivableModules:a})=>{let o={transport:e,remoteUuid:n,sendMessage:i,eventTarget:r,revivableModules:a};for(let e of a)e.init?.(o);let{promise:s,resolve:c}=Promise.withResolvers();return r.addEventListener(`message`,function e({detail:t}){t.type===`init`&&(c(t.data),r.removeEventListener(`message`,e))}),i({type:`init`,remoteUuid:n,data:yv(t,o)}),{revivableContext:o,remoteValue:s.then(e=>xv(e,o))}},Tv=e=>{if(!(wm(e.transport)&&Tm(e.transport)))return;if(e.protocolEventTarget.addEventListener(`message`,({detail:{message:t,peer:n}})=>{if(t.type===`announce`){if(!t.remoteUuid){e.sendMessage({type:`announce`,remoteUuid:t.uuid});return}if(t.remoteUuid!==e.getUuid()||e.connectionContexts.has(t.uuid))return;e.sendMessage({type:`announce`,remoteUuid:t.uuid});let r=e.createConnectionEventTarget(),i={...n(),abort:()=>e.abortConnection(t.uuid)},a;try{let n=e.valueFor(i);if(e.claimPendingAbort(t.uuid)){e.sendMessage({type:`close`,remoteUuid:t.uuid});return}a=wv({transport:e.transport,value:n,remoteUuid:t.uuid,eventTarget:r,send:t=>e.sendMessage(t),revivableModules:e.revivableModules})}catch(n){e.sendMessage({type:`close`,remoteUuid:t.uuid}),e.rejectRemoteValue(n);return}let o={type:`bidirectional`,eventTarget:r,connection:a};e.connectionContexts.set(t.uuid,o),o.connection.remoteValue.then(t=>e.addConnection(i,t),t=>e.rejectRemoteValue(t));return}if(t.type===`close`){if(t.remoteUuid!==e.getUuid())return;let n=e.connectionContexts.get(t.uuid);if(!n)return;e.connectionContexts.delete(t.uuid),mh(n.connection.revivableContext),e.rejectRemoteValue(Error(`osra: peer closed the connection`));return}if(t.remoteUuid!==e.getUuid())return;let r=e.connectionContexts.get(t.uuid);r&&r.eventTarget.dispatchEvent(new CustomEvent(`message`,{detail:t}))}),e.presetRemoteUuid!==void 0){let t=e.presetRemoteUuid,n=e.createConnectionEventTarget(),r,i;try{i={abort:()=>e.abortConnection(t)};let a=e.valueFor(i);if(e.claimPendingAbort(t)){e.sendMessage({type:`close`,remoteUuid:t});return}r=wv({transport:e.transport,value:a,remoteUuid:e.presetRemoteUuid,eventTarget:n,send:t=>e.sendMessage(t),revivableModules:e.revivableModules})}catch(n){e.sendMessage({type:`close`,remoteUuid:t}),e.rejectRemoteValue(n);return}let a={type:`bidirectional`,eventTarget:n,connection:r};e.connectionContexts.set(e.presetRemoteUuid,a),a.connection.remoteValue.then(t=>e.addConnection(i,t),t=>e.rejectRemoteValue(t));return}let t=50,n,r=()=>{if(!(e.unregisterSignal?.aborted||e.connectionContexts.size>0)){try{e.sendMessage({type:`announce`},`*`)}catch{}n=setTimeout(r,t),t=Math.min(t*2,1e3)}};e.unregisterSignal?.addEventListener(`abort`,()=>clearTimeout(n),{once:!0}),r()},Ev=()=>new EventTarget,Dv=e=>{let t=km(e),n=t?e.emit:e,r=t?e.receive:e;return{isJson:t&&`isJson`in e&&e.isJson!==void 0?e.isJson:n!==void 0&&Cm(n)||r!==void 0&&Cm(r),...n===void 0?{}:{emit:n},...r===void 0?{}:{receive:r}}},Ov=e=>e?e(av):av,kv=32,Av=()=>{let e=[],t=new Set,n=!1,r=()=>({value:void 0,done:!0});return{push:r=>{if(!n){if(t.size===0){e.push(r),e.length>kv&&e.shift();return}for(let e of t){let t=e.wake;if(t){e.wake=void 0,t({value:r,done:!1});continue}e.buffered.push(r)}}},close:()=>{n=!0;for(let e of t){let t=e.wake;e.wake=void 0,t?.(r())}},iterate:()=>{let i={buffered:[...e]};t.add(i);let a=!1;return{[Symbol.asyncIterator](){return this},next:()=>{if(a)return Promise.resolve(r());let e=i.buffered.shift();return e?Promise.resolve({value:e,done:!1}):n?Promise.resolve(r()):new Promise(e=>{i.wake=e})},return:()=>{a=!0,t.delete(i);let e=i.wake;return i.wake=void 0,e?.(r()),Promise.resolve(r())}}}}},jv=(e,t,n)=>{let r=e.then(n);r.catch(()=>{});let i=()=>{let e=t.iterate();return{[Symbol.asyncIterator](){return this},next:()=>e.next().then(e=>e.done?{value:void 0,done:!0}:{value:n(e.value),done:!1}),return:()=>e.return?.()??Promise.resolve({value:void 0,done:!0})}};return Object.assign(r,{[Symbol.asyncIterator]:i})},Mv=Symbol.for(`osra.context`),Nv=e=>typeof e==`object`&&!!e&&Mv in e,Pv=[Sv],Fv=(e,{transport:t,name:n,remoteName:r,key:i=Hp,origin:a=`*`,unregisterSignal:o,revivableModules:s,uuid:c,remoteUuid:l,connection:u=({value:e})=>e})=>{let d=u,f=Dv(t);if(!(wm(f)&&Tm(f))){let e=Av();e.close();let t=Promise.reject(Error(`osra: transport must be able to both emit and receive to establish a connection; pass a bidirectional platform transport or a custom { emit, receive } pair`));return t.catch(()=>{}),jv(t,e,d)}let p=Ov(s),m=new Map,h=new Set,g=Av(),{promise:_,resolve:v,reject:y}=Promise.withResolvers();_.catch(()=>{});let b=c??globalThis.crypto.randomUUID(),x=(e,t=a)=>{let r={[Vp]:i,name:n,uuid:b,...e},o=jh(r);Zp(f,r,t,o),sg(o)},S=(e,t)=>{o?.aborted||x(e,t)},C=Ev(),w={transport:f,valueFor:t=>Nv(e)?e[Mv](t):e,revivableModules:p,connectionContexts:m,getUuid:()=>b,presetRemoteUuid:l,sendMessage:S,protocolEventTarget:C,rejectRemoteValue:y,abortConnection:e=>{let t=m.get(e);if(!t){h.add(e);return}m.delete(e),x({type:`close`,remoteUuid:e}),mh(t.connection.revivableContext),y(Error(`osra: connection aborted`))},claimPendingAbort:e=>h.delete(e),addConnection:(e,t)=>{let n={value:t,context:e};v(n),g.push(n)},createConnectionEventTarget:Ev,unregisterSignal:o};if(Jp({listener:(e,t)=>{e.uuid!==b&&C.dispatchEvent(new CustomEvent(`message`,{detail:{message:e,peer:()=>({...t.origin?{origin:t.origin}:{},...t.source?{source:t.source}:{},...t.port?{port:t.port}:{},...t.sender?{sender:t.sender}:{}})}}))},transport:f,remoteName:r,key:i,origin:a,unregisterSignal:o}),o?.aborted)return y(o.reason),g.close(),jv(_,g,d);o?.addEventListener(`abort`,()=>{for(let[e,t]of m)x({type:`close`,remoteUuid:e}),mh(t.connection.revivableContext);m.clear(),g.close(),y(o.reason)},{once:!0});for(let e of Pv)e.init(w);return jv(_,g,d)},Iv=(e,t)=>Fv(e,t);const Lv={kind:`Document`,definitions:[{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`Episode`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Stable unique identifier that persists across URI changes and source additions`,block:!0},name:{kind:`Name`,value:`_id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Uri consists of the `origin` and `id` fields in the format `origin:id`",block:!0},name:{kind:`Name`,value:`uri`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"String that is used to target a specific origin, e.g `google` or `yt` for youtube",block:!0},name:{kind:`Name`,value:`origin`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An id that references a specific resource within the origin space`,block:!0},name:{kind:`Name`,value:`id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An url to the media resource`,block:!0},name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Uri to the media resource`,block:!0},name:{kind:`Name`,value:`mediaUri`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Every other row this episode is related to. See `MediaHandle` for why the relation is explicit.",block:!0},name:{kind:`Name`,value:`handles`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeHandle`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`titles`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeTitle`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`shortDescriptions`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeShortDescriptionInput`}},directives:[]}],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeShortDescription`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`descriptions`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeDescriptionInput`}},directives:[]}],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeDescription`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`releaseDate`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`relativeNumber`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`absoluteNumber`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`thumbnails`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeThumbnail`}}}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`URL for an embeddable player iframe`,block:!0},name:{kind:`Name`,value:`embedUrl`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`seasonNumber`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`episodeNumber`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`absoluteEpisodeNumber`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Runtime in minutes`,block:!0},name:{kind:`Name`,value:`runtime`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`EpisodeTitle`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`title`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`EpisodeShortDescriptionInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`type`},type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeDescriptionContentType`}},defaultValue:{kind:`EnumValue`,value:`TEXT`},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`count`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`EpisodeShortDescription`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`shortDescription`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`EpisodeDescriptionContentType`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`HTML`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`TEXT`},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`EpisodeDescriptionInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`type`},type:{kind:`NamedType`,name:{kind:`Name`,value:`EpisodeDescriptionContentType`}},defaultValue:{kind:`EnumValue`,value:`TEXT`},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`count`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`EpisodeDescription`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`description`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`EpisodeThumbnail`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`height`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`width`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Average #hex color of cover image`,block:!0},name:{kind:`Name`,value:`color`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:"One edge out of an episode. Shares `MediaHandleRelation` with media on purpose: the two questions are\nthe same question, and a second enum with the same two values would drift.",block:!0},name:{kind:`Name`,value:`EpisodeHandle`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The related row. Carries its own uri, origin, id and url.`,block:!0},name:{kind:`Name`,value:`node`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Episode`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`What this edge asserts. Only SAME_AS unions clusters.`,block:!0},name:{kind:`Name`,value:`relation`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaHandleRelation`}}},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`MediaType`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`TV`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`A televised run of very short episodes. Its own member rather than a TV with a small \`episodeCount\`,
112
+ because AniList publishes the distinction and a viewer filtering for shorts is asking for exactly it.
113
+
114
+ ONLY ANILIST EVER EMITS IT, and AniList loses \`type\` to jikan, which scores 0.9 against 0.8 and
115
+ spells the same show TV. So a short jikan also carries profiles as TV in the aggregate and answers a
116
+ TV filter rather than a TV_SHORT one. That is a known subset, not a bug to work around here: making
117
+ it exact means changing which source wins \`type\`, and that precedence is what keeps a stale dump from
118
+ overwriting a live catalogue (store/aggregate.ts:203, sources/offline/normalize.ts:19-31).
119
+
120
+ INVISIBLE TO THE MERGE, and that takes real code rather than an omission. \`mergeType\` in
121
+ store/fuzzy-merge.ts folds it back to TV before a cluster is profiled, because every gate in that
122
+ file was calibrated on a corpus where AniList's shorts arrived spelled TV. Reading the new member
123
+ there would move two profiles at once on a cluster AniList alone types, and an empty work-kind set
124
+ disables the companion-content veto outright.`,block:!0},name:{kind:`Name`,value:`TV_SHORT`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`MOVIE`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`ANIME`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Special episodes that have been included in DVD/Blu-ray releases, picture dramas, pilots, etc`,block:!0},name:{kind:`Name`,value:`SPECIAL`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`(Original Video Animation) Anime that have been released directly on
125
+ DVD/Blu-ray without originally going through a theatrical release or
126
+ television broadcast`,block:!0},name:{kind:`Name`,value:`OVA`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`(Original Net Animation) Anime that have been originally released online or are only available through streaming services.`,block:!0},name:{kind:`Name`,value:`ONA`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Live action media such as movies or TV show`,block:!0},name:{kind:`Name`,value:`LIVE_ACTION`},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`MediaStatus`},directives:[],values:[{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Has completed and is no longer being released`,block:!0},name:{kind:`Name`,value:`FINISHED`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Currently releasing`,block:!0},name:{kind:`Name`,value:`RELEASING`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`To be released at a later date`,block:!0},name:{kind:`Name`,value:`NOT_YET_RELEASED`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Ended before the work could be finished`,block:!0},name:{kind:`Name`,value:`CANCELLED`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Is currently paused from releasing and will resume at a later date`,block:!0},name:{kind:`Name`,value:`HIATUS`},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:`The broadcast season a run aired in.
127
+
128
+ Named by the SOURCE, never derived from \`startDate\` here. Seven extractors coerce a bare year into
129
+ January 1 and two answer YYYY-MM-01 for a month-only date (see \`namesADay\` in sources/season.ts), so
130
+ deriving a season from a start date would file every year-only row under WINTER.`,block:!0},name:{kind:`Name`,value:`MediaSeason`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`WINTER`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`SPRING`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`SUMMER`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`FALL`},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:`Broad content category. A media can belong to several (e.g. an anime film is ANIME + MOVIE).`,block:!0},name:{kind:`Name`,value:`MediaCategory`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`ANIME`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`An episodic series (TV / live-action / web).`,block:!0},name:{kind:`Name`,value:`SERIES`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`MOVIE`},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:`What a handle asserts about the media carrying it. STRUCTURAL only: identity and containment.
131
+
132
+ Narrative relations between different works (prequel, sequel, adaptation, side story) are a SEPARATE
133
+ axis and will get their own \`MediaRelation\` enum on their own field. They are deliberately not mixed:
134
+ PREQUEL says nothing about whether two rows are the same media, and SAME_AS says nothing about story
135
+ order. One enum spanning both would mean neither.`,block:!0},name:{kind:`Name`,value:`MediaHandleRelation`},directives:[],values:[{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`The handle names THIS run. The only relation that unions clusters, in \`upsertMedia\`, and the union
136
+ has NO INVERSE: once two media are welded they stay welded for the session.
137
+
138
+ Minting this for an id that names a SHOW is the single most expensive mistake available here. It
139
+ merged three Mushoku Tensei seasons, four Demon Slayer films and fifteen Dragon Ball Z films, each
140
+ time because one id was the only thing a source could offer and the only relation was this one.`,block:!0},name:{kind:`Name`,value:`SAME_AS`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`This media is one PART of what the handle names: a run of that show, a film published under that
141
+ series, a season of that title.
142
+
143
+ It carries the handle's url WITHOUT claiming to be it, so a show-level id is worth keeping instead
144
+ of being dropped. It never unions, so no number of these can weld two runs together. What it costs
145
+ is that nothing may read episodes, titles, covers or any other metadata across it: the thing on the
146
+ other end is a bigger thing, and its episode list is every run's at once.`,block:!0},name:{kind:`Name`,value:`PART_OF`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`This media HOLDS what the handle names: a season of this run, a part of this compilation, a range
147
+ of episodes another packaging carries. The inverse direction of \`PART_OF\`, and it unions nothing.
148
+
149
+ A run's page lists the catalogue seasons that hold it, a run split across seasons lists them all,
150
+ and a container page lists its own seasons. It renders as a LINK and never as a button: the badge
151
+ reader takes "SAME_AS first then anything" and playback takes SAME_AS only, so nothing here can
152
+ place a play button on a row the store has not proven.`,block:!0},name:{kind:`Name`,value:`INCLUDES`},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:'Which PAGE a row draws, as distinct from which identity space it lives in.\n\n`MediaScope` answers "what does SAME_AS mean here"; this answers "what does this page look like". A\n`FOLD` is a catalogue season whose every member is a part or an inclusion of some run: it draws its\nOWN rows in its OWN numbering rather than following to the run, which is what a bookmark on such a\nseason has to open. `RUN` and `CONTAINER` mean what they mean on `MediaScope`.',block:!0},name:{kind:`Name`,value:`MediaKind`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`RUN`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`CONTAINER`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`FOLD`},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:`Which kind of thing a row names, and so which identity space its SAME_AS claims union in.
153
+
154
+ Sameness is only ever asserted within one scope. A claim that crosses scopes is read as PART_OF,
155
+ whatever the producer asked for: a run is part of its show, never the same thing as it.`,block:!0},name:{kind:`Name`,value:`MediaScope`},directives:[],values:[{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`One broadcast run: a cour, a film. The unit this store aggregates and the unit a card shows.`,block:!0},name:{kind:`Name`,value:`RUN`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`A show, a series, a franchise page: something several runs are part of.`,block:!0},name:{kind:`Name`,value:`CONTAINER`},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:`How one work relates to another as a STORY. The other axis, and never mixed with \`MediaHandleRelation\`.
156
+
157
+ That enum answers "are these the same thing", this one answers "how does this story connect to that
158
+ one", and the schema has kept them apart deliberately since the handle enum was written: PREQUEL says
159
+ nothing about sameness and SAME_AS says nothing about story order. Nothing here may ever union a
160
+ cluster. A sequel is a DIFFERENT work, and treating one as the same row is the mistake that merged
161
+ three Mushoku Tensei seasons when it was made with SAME_AS.
162
+
163
+ The values are AniList's set (\`relationType(version: 2)\`), which is the widest of the vocabularies in
164
+ play and the one MyAnimeList's own relation names map into without inventing anything. Confirmed
165
+ against live data 2026-09-08: anilist 108465 answers SOURCE, ALTERNATIVE and SEQUEL.`,block:!0},name:{kind:`Name`,value:`MediaRelation`},directives:[],values:[{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`This work adapts the other, which is usually the manga or novel it came from.`,block:!0},name:{kind:`Name`,value:`ADAPTATION`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`The other work comes first in the story.`,block:!0},name:{kind:`Name`,value:`PREQUEL`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`The other work comes after.`,block:!0},name:{kind:`Name`,value:`SEQUEL`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`The other work is the parent story this one hangs off.`,block:!0},name:{kind:`Name`,value:`PARENT`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`A story beside the main one rather than before or after it.`,block:!0},name:{kind:`Name`,value:`SIDE_STORY`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`The other work follows a character out of this one.`,block:!0},name:{kind:`Name`,value:`CHARACTER`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`A recap or digest of the other work.`,block:!0},name:{kind:`Name`,value:`SUMMARY`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`A different telling of the same story.`,block:!0},name:{kind:`Name`,value:`ALTERNATIVE`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`A work spun out of this one, sharing a world rather than a plot.`,block:!0},name:{kind:`Name`,value:`SPIN_OFF`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`The material this work was adapted FROM. The inverse of ADAPTATION.`,block:!0},name:{kind:`Name`,value:`SOURCE`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Several works collected into one release.`,block:!0},name:{kind:`Name`,value:`COMPILATION`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`This work contains the other.`,block:!0},name:{kind:`Name`,value:`CONTAINS`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Related, in a way the source did not name.`,block:!0},name:{kind:`Name`,value:`OTHER`},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:`One narrative edge out of a media: what it relates to, and how.
166
+
167
+ The node is a SNAPSHOT and not necessarily a row this store has ever fetched. A franchise runs to
168
+ dozens of entries and resolving each before anything could render would make one modal cost dozens of
169
+ requests, so the edge carries what a card and a graph node need (uri, titles, format, status, cover,
170
+ episode count, start date) and nothing else is promised. Opening one navigates to its uri, and the
171
+ store fills that row in properly at that point.
172
+
173
+ Same shape as \`MediaHandle\` on purpose, so the same components render both.`,block:!0},name:{kind:`Name`,value:`MediaRelationEdge`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`What this edge claims about the story. Never about identity.`,block:!0},name:{kind:`Name`,value:`relation`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaRelation`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The related work, as much of it as the naming source supplied.`,block:!0},name:{kind:`Name`,value:`node`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Media`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"What KIND of work the other end is, in the naming source's own words: `TV`, `MOVIE`, `MANGA`,\n`NOVEL`, `ONE_SHOT`.\n\nA string, and on the EDGE rather than on the node, for one reason: `MediaType` is anime formats\nonly, and a franchise's relations are mostly NOT anime. The novel a show adapts is the single most\nuseful relation there is and it cannot be spelled in that enum. Widening `MediaType` to hold it\nwould reach `mergeType` in store/fuzzy-merge.ts and every filter built on it, to carry something\nonly ever displayed; the enum's own comment records what moving it costs.\n\nDISPLAY ONLY. Nothing may branch on it.",block:!0},name:{kind:`Name`,value:`format`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:`One work in a franchise graph, thin enough that a whole series fits in one payload.`,block:!0},name:{kind:`Name`,value:`MediaFranchiseNode`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`What a click navigates to. Also the id the edges below join on.`,block:!0},name:{kind:`Name`,value:`uri`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`titles`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaTitle`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`covers`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaCover`}}}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"The naming source's own word for the kind of work. Display only, as on `MediaRelationEdge`.",block:!0},name:{kind:`Name`,value:`format`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`status`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaStatus`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`episodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`startDate`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:"One arrow in a franchise graph, joining two `MediaFranchiseNode` uris.",block:!0},name:{kind:`Name`,value:`MediaFranchiseEdge`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`from`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`to`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`relation`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaRelation`}}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:`Every work in one series, and how they connect: the whole graph rather than one media's own edges.
174
+
175
+ WHY IT IS NOT JUST \`relations\` WALKED. Following every edge leaks out of the franchise entirely. A
176
+ crossover promotional short relates BY CHARACTER to each series taking part, so two hops out of
177
+ \`That Time I Got Reincarnated as a Slime\` reaches Attack on Titan, Fire Force, Chihayafuru and seven
178
+ other unrelated shows. Measured 2026-09-08 against live AniList: following every edge reached 36
179
+ works of which 10 were off-franchise, while following only the STORY edges reached 21 works and none.
180
+
181
+ So CHARACTER and OTHER are reported as relations and never TRAVERSED. They answer "who appears in
182
+ this" and "these are connected somehow", neither of which is "this is the same series".`,block:!0},name:{kind:`Name`,value:`MediaFranchise`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`nodes`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaFranchiseNode`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`edges`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaFranchiseEdge`}}}}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:`One edge out of a media: which row, and what the edge claims about it.`,block:!0},name:{kind:`Name`,value:`MediaHandle`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The related row. Carries its own uri, origin, id and url.`,block:!0},name:{kind:`Name`,value:`node`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Media`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`What this edge asserts. Only SAME_AS unions clusters.`,block:!0},name:{kind:`Name`,value:`relation`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaHandleRelation`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Where this handle came from, when it did not come from the source's own data.
183
+
184
+ Unset, which is every handle a resolver builds out of its own payload, means the source's own
185
+ statement and the store consumes it. \`address\` means the handle was rebuilt from the asked
186
+ aggregated uri by \`buildHandlesFromUri\` (\`src/sources/utils.ts\`): the address names WHICH sources to
187
+ ask and asserts nothing about how the rows relate, so such a claim routes a re-ask and enters no
188
+ cluster. No other value is defined; an unknown one reads as unset.`,block:!0},name:{kind:`Name`,value:`provenance`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"WHY this handle is here, in the deriving rule's own word: `member`, `placeholder`, or the reason a\ncontainment link carried (`asserted`, `span`, `contested`, `prefix`). Null on a handle no plugin\nderived. Display and diagnosis only; nothing may branch on it.",block:!0},name:{kind:`Name`,value:`via`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Which plugin put it here, e.g. `plugin:aggregate`. Null outside the graph store.",block:!0},name:{kind:`Name`,value:`by`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:"Where ONE field of an aggregated media got its value, and under which rule.\n\nRead by the trace panel, so a wrong field is a question with an answer instead of a screenshot. A\nper-field rule names one `uri`; a vote names every `uris` that backed it with the deciding `tier` and\nits `witnesses`. `answerSeq` is the supplying member's `fieldSeq[field]`, which is the exact answer\nbehind the value.",block:!0},name:{kind:`Name`,value:`MediaFieldProvenance`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`field`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`uri`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`uris`},arguments:[],type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`answerSeq`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`tier`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`witnesses`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`rule`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]}]},{kind:`ObjectTypeDefinition`,description:{kind:`StringValue`,value:`One rule the store evaluated over the whole graph that this media's cluster does not satisfy.
189
+
190
+ Reported, never repaired: an anomaly is a statement about the sources disagreeing, and hiding it
191
+ would make the disagreement look like a decision.`,block:!0},name:{kind:`Name`,value:`MediaAnomaly`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`rule`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`detail`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`Media`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Stable unique identifier that persists across URI changes and source additions`,block:!0},name:{kind:`Name`,value:`_id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Uri consists of the `origin` and `id` fields in the format `origin:id`",block:!0},name:{kind:`Name`,value:`uri`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"String that is used to target a specific origin, e.g `google` or `yt` for youtube",block:!0},name:{kind:`Name`,value:`origin`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An id that references a specific resource within the origin space`,block:!0},name:{kind:`Name`,value:`id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An url to the media resource`,block:!0},name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Every other row this media is related to, and what each relation actually claims.
192
+
193
+ Was \`[Media!]!\`, a bare list, which forced one relation on everything: a handle either asserted
194
+ sameness or did not exist. That is why a source holding only a show-level id had to choose between
195
+ lying and staying silent, and why \`worker/store/db.ts\` had to special-case IMDb out of the graph
196
+ entirely rather than carry its link.`,block:!0},name:{kind:`Name`,value:`handles`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaHandle`}}}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Every work this one is related to as a STORY: prequels, sequels, the novel it adapts, side stories.\n\nSeparate from `handles`, which is about identity. See `MediaRelation`. Empty rather than null when a\nsource named none, which is most of them: only AniList supplies these today.",block:!0},name:{kind:`Name`,value:`relations`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaRelationEdge`}}}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The whole series this work belongs to, as a graph. Null where no source could supply one, which is
197
+ most of them. NULLABLE deliberately: a non-null list that a source omits nulls the media carrying
198
+ it, taking the rest of the payload with it.`,block:!0},name:{kind:`Name`,value:`franchise`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaFranchise`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Which identity space this row lives in. An absent value reads as RUN.`,block:!0},name:{kind:`Name`,value:`scope`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaScope`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Which page this row draws (`MediaKind`). Null from a store that does not compute it, which reads as\n`scope`.",block:!0},name:{kind:`Name`,value:`kind`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaKind`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Which member supplied each field, and under which rule. Null from a store that records none.
199
+
200
+ NULLABLE on purpose, like \`franchise\`: a non-null list absent from a payload nulls the media
201
+ carrying it, and a listing card records no provenance.`,block:!0},name:{kind:`Name`,value:`provenance`},arguments:[],type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaFieldProvenance`}}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Every anomaly the store filed against this row's cluster. Null where none were evaluated.`,block:!0},name:{kind:`Name`,value:`anomalies`},arguments:[],type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaAnomaly`}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`titles`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaTitle`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`type`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaType`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Broad categories this media belongs to (anime / series / movie); can be several.`,block:!0},name:{kind:`Name`,value:`categories`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaCategory`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`status`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaStatus`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`shortDescriptions`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaShortDescriptionInput`}},directives:[]}],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaShortDescription`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`descriptions`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaDescriptionInput`}},directives:[]}],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaDescription`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`trailers`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaTrailer`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`covers`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaCover`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`banners`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaBanner`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`averageScore`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`popularity`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`startDate`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`endDate`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`isAdult`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Boolean`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`episodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The soonest episode a source has scheduled that has not aired yet, or null.
202
+
203
+ Derived from AniList's airing schedule, which was already fetched for \`startDate\`, so it costs no
204
+ request. Null means "nobody scheduled anything ahead of now", which covers a finished run and a
205
+ source that publishes no schedule alike: it is not a promise that the run has ended.`,block:!0},name:{kind:`Name`,value:`nextAiringEpisode`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaAiringEpisode`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The broadcast season this run aired in, as the source named it.`,block:!0},name:{kind:`Name`,value:`season`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaSeason`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The calendar year \`season\` belongs to.
206
+
207
+ Separate from \`startDate\` because it survives a coerced date: a source that only knows the year
208
+ still files the run under the right season when another source names one, and a January premiere
209
+ stays in the WINTER of its own year rather than the FALL of the year before.`,block:!0},name:{kind:`Name`,value:`seasonYear`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Broad content descriptors, deduplicated across the cluster, richest source first.
210
+
211
+ Free-form strings rather than an enum because no two catalogues agree on a fixed set, and an enum
212
+ would have to drop every value it had not anticipated. Supplied by AniList and jikan; the bundled
213
+ offline catalogue publishes none, so a genre filter cannot be answered during an upstream outage.`,block:!0},name:{kind:`Name`,value:`genres`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Finer-grained descriptors than \`genres\`, from AniList's own tag vocabulary.
214
+
215
+ Kept apart from genres rather than merged into one list because AniList publishes them separately
216
+ and its own browse UI groups them separately, so a merged list could not reproduce either. Tags
217
+ AniList marks as a spoiler are dropped at the source and never reach here.`,block:!0},name:{kind:`Name`,value:`tags`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`episodes`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Episode`}}}}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaTitle`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`title`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`MediaShortDescriptionInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`type`},type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaDescriptionContentType`}},defaultValue:{kind:`EnumValue`,value:`TEXT`},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`count`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaShortDescription`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`shortDescription`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`MediaDescriptionContentType`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`HTML`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`TEXT`},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`MediaDescriptionInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`type`},type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaDescriptionContentType`}},defaultValue:{kind:`EnumValue`,value:`TEXT`},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`count`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaDescription`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`description`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaTrailer`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Uri consists of the `origin` and `id` fields in the format `origin:id`",block:!0},name:{kind:`Name`,value:`uri`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"String that is used to target a specific origin, e.g `google` or `yt` for youtube",block:!0},name:{kind:`Name`,value:`origin`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An id that references a specific resource within the origin space`,block:!0},name:{kind:`Name`,value:`id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An url to the media resource`,block:!0},name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`thumbnail`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaAiringEpisode`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Which episode of the run this is, as the source numbers it.`,block:!0},name:{kind:`Name`,value:`episodeNumber`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`When it airs.`,block:!0},name:{kind:`Name`,value:`airingAt`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaCover`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`height`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`width`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Average #hex color of cover image`,block:!0},name:{kind:`Name`,value:`color`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaBanner`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`language`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`height`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`width`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Average #hex color of cover image`,block:!0},name:{kind:`Name`,value:`color`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`score`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Float`}},directives:[]}]},{kind:`InputObjectTypeDefinition`,description:{kind:`StringValue`,value:`What the app asked for at the TOP of the call, so a source can tell a detail view from a listing.
218
+
219
+ THE WORKER WRITES THIS. Every field is regenerated from the worker's own registry at each source's
220
+ boundary before the arguments are coerced, so a value supplied by a caller is replaced rather than
221
+ trusted, and only \`token\` is ever read off the wire. Nullable because the app's own documents send
222
+ none: they are validated by the app-level server before the fan-out that stamps them runs.`,block:!0},name:{kind:`Name`,value:`RequestContext`},directives:[],fields:[{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Identifies THIS hop to the worker. The only field read back off the wire.`,block:!0},name:{kind:`Name`,value:`token`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`ID`}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Stable for the whole call tree, so a source may memoize per root rather than per hop.`,block:!0},name:{kind:`Name`,value:`rootId`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`ID`}}},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`operation`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`RootOperation`}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`The origins already on the stack, nearest last. A source seeing itself here is in a cycle.`,block:!0},name:{kind:`Name`,value:`chain`},type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}}},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`RootOperation`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`MEDIA`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`MEDIA_PAGE`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`SIMILAR_MEDIA`},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`MediaInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`uri`},type:{kind:`NamedType`,name:{kind:`Name`,value:`ID`}},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`context`},type:{kind:`NamedType`,name:{kind:`Name`,value:`RequestContext`}},directives:[]}]},{kind:`EnumTypeDefinition`,description:{kind:`StringValue`,value:`How a page is ordered. A bare member sorts ASCENDING and its \`_DESC\` twin descending, the reading the
223
+ suffix carries in every enum of this shape, AniList's \`MediaSort\` included, which these two members
224
+ are borrowed from. A media the sources give no value for sorts LAST in both directions.
225
+
226
+ Naming more than one member runs them in order and the last one decides.`,block:!0},name:{kind:`Name`,value:`MediaSort`},directives:[],values:[{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Least popular first.`,block:!0},name:{kind:`Name`,value:`POPULARITY`},directives:[]},{kind:`EnumValueDefinition`,description:{kind:`StringValue`,value:`Most popular first. What the home row and the search page ask for.`,block:!0},name:{kind:`Name`,value:`POPULARITY_DESC`},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`MediaPageInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`context`},type:{kind:`NamedType`,name:{kind:`Name`,value:`RequestContext`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by media IDs`,block:!0},name:{kind:`Name`,value:`nodes`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaInput`}}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by search terms`,block:!0},name:{kind:`Name`,value:`search`},type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by the media's current release status`,block:!0},name:{kind:`Name`,value:`status`},type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaStatus`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by category (anime / series / movie); media matching ANY of these are kept.`,block:!0},name:{kind:`Name`,value:`categories`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaCategory`}}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:"Filter by format; media whose `type` is ANY of these are kept. A media with no type is dropped.",block:!0},name:{kind:`Name`,value:`formats`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaType`}}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by broadcast season. Pair it with \`seasonYear\` to name one season rather than every WINTER.
227
+
228
+ A source that can answer a season directly is asked for THIS one instead of the clock's; a source
229
+ that cannot answers nothing rather than answering the current season, which would look like a
230
+ result set and be the wrong year.`,block:!0},name:{kind:`Name`,value:`season`},type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaSeason`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:"Filter by the year of `season`.",block:!0},name:{kind:`Name`,value:`seasonYear`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by genre; media carrying ALL of these are kept, compared case-insensitively.`,block:!0},name:{kind:`Name`,value:`genres`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by tag; media carrying ALL of these are kept, compared case-insensitively.`,block:!0},name:{kind:`Name`,value:`tags`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`sorts`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaSort`}}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by the start date of the media`,block:!0},name:{kind:`Name`,value:`startDate`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Filter by the end date of the media`,block:!0},name:{kind:`Name`,value:`endDate`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Cursor from where to start`,block:!0},name:{kind:`Name`,value:`at`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`How many pages before the cursor to return`,block:!0},name:{kind:`Name`,value:`before`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`How many pages after the cursor to return`,block:!0},name:{kind:`Name`,value:`after`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`MediaPage`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The current page`,block:!0},name:{kind:`Name`,value:`firstPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The current page`,block:!0},name:{kind:`Name`,value:`previousPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The current page`,block:!0},name:{kind:`Name`,value:`currentPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The first page`,block:!0},name:{kind:`Name`,value:`nextPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The last page cursor`,block:!0},name:{kind:`Name`,value:`lastPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Total number of items on the current page`,block:!0},name:{kind:`Name`,value:`currentPageNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The total number of items. Note: This value is not guaranteed to be accurate, do not rely on this for logic`,block:!0},name:{kind:`Name`,value:`totalNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Total number of items before the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic`,block:!0},name:{kind:`Name`,value:`beforeCurrentPageNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Total number of items after the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic`,block:!0},name:{kind:`Name`,value:`afterCurrentPageNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The media page nodes`,block:!0},name:{kind:`Name`,value:`nodes`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Media`}}}}},directives:[]}]},{kind:`InputObjectTypeDefinition`,description:{kind:`StringValue`,value:`The run a caller is looking for, described by EVIDENCE about its own run and never by a season number.
231
+
232
+ Stub models a broadcast run; every catalogue models a show with seasons hanging off it, and no two
233
+ catalogues number those seasons the same way. Netflix folds two cours into one season (its season 2 of
234
+ Mushoku Tensei is 25 episodes over anime's 13 and 12), JustWatch numbers by its own list, anime metadata
235
+ says "Season 2 Part 2". Two numberings in one id space collide: on 2026-09-05 anime season 1 (11
236
+ episodes, no ordinal in its title) took \`nf:80987039-3\` by episode count while season 3 took the same id
237
+ by its ordinal, and \`graph.link\` has no inverse. So a caller holding a show-level id says what it knows
238
+ about ITS run and the owning origin answers with the one run of that show the evidence establishes, or
239
+ with null.
240
+
241
+ What counts as established is decided in ONE place, \`sources/similar.ts\`, and every answering source
242
+ goes through it: a season premiere within 45 days of a day-precise start, episode titles covering most
243
+ of a season, an ordinal every title agrees on with an episode count the season does not exceed, the
244
+ one season dated our year holding no more than our count, or the first season holding our episodes. A
245
+ season holding MORE episodes than the run is a fold of several runs and is never the answer, and a
246
+ season whose length is unknown cannot be shown not to be one. Anything ambiguous is null.
247
+
248
+ The rules decide WHICH season of the show and never WHICH show: \`showId\` settles that, and it came off
249
+ a PART_OF edge whose container cluster a listing's fuzzy title pass may have unioned, so an answer is
250
+ only as right as that union.`,block:!0},name:{kind:`Name`,value:`SimilarMediaInput`},directives:[],fields:[{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`The show's id in the ANSWERING origin's own space: a Crunchyroll series id, a Netflix title id, a JustWatch node objectId.`,block:!0},name:{kind:`Name`,value:`showId`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`ID`}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:"When our run started. A date naming a DAY is matched within 45 days; a bare year (`YYYY-01-01`) vetoes a season dated another year and, with an episode count on both sides, names the one season dated ours.",block:!0},name:{kind:`Name`,value:`startDate`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Date`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`Every title the caller knows for its run. Read for the season ordinals they agree on, never for the franchise: the show id already settles that.`,block:!0},name:{kind:`Name`,value:`titles`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`How many episodes our run has. A season holding more is a fold of several runs and is refused.`,block:!0},name:{kind:`Name`,value:`episodeCount`},type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`InputValueDefinition`,description:{kind:`StringValue`,value:`The titles of our run's episodes, when the caller has them. A season most of whose episode titles we carry is ours; one sharing none is not, whatever its number.`,block:!0},name:{kind:`Name`,value:`episodeTitles`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}}},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`context`},type:{kind:`NamedType`,name:{kind:`Name`,value:`RequestContext`}},directives:[]}]},{name:{kind:`Name`,value:`Subscription`},kind:`ObjectTypeDefinition`,fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`media`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaInput`}}},directives:[]}],type:{kind:`NamedType`,name:{kind:`Name`,value:`Media`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`mediaPage`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaPageInput`}}},directives:[]}],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`MediaPage`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The one run of \`showId\` that is the caller's run by the evidence given, or null.
251
+
252
+ The answer is a RUN at the answering origin and carries no handle naming another run: the CALLER
253
+ decides what to claim about it. Null is the expected answer and never an error: no such show, no
254
+ evidence that settles it, or evidence fitting two seasons. Answering with the SHOW here, or with a
255
+ season the evidence merely fails to contradict, recreates the weld the caller asked in order to avoid.`,block:!0},name:{kind:`Name`,value:`similarMedia`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`SimilarMediaInput`}}},directives:[]}],type:{kind:`NamedType`,name:{kind:`Name`,value:`Media`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"The one run of `showId` that HOLDS the caller's run without being it, or null.\n\nThe other half of the fold, and a SEPARATE FIELD rather than a widened `similarMedia` payload: this\nanswer means something different about the same evidence, and every source that answers `similarMedia`\ntoday returns `Media` from it. A source that cannot tell a container from a run simply never\nimplements this one and is asked nothing.\n\nNetflix is the worked example. Its season 1 of Mushoku Tensei holds 24 episodes over anime's 11 and\n12, so `similarMedia` refuses it for both runs and is right to: a season longer than the run is not\nthe run. It is still where the run is, and this is how the run gets to say so. The answer is the\nCONTAINER SEASON as a run of the answering origin, carrying its own episodes and its own count,\nbecause a caller claiming `PART_OF` from it needs both to place anything on the run.\n\nNull is the expected answer and never an error. The evidence is `pickContainingSeason` in\n`src/sources/similar.ts`, which refuses anything a count alone would have to guess at, and which\nanswers nothing at all for a run `similarMedia` could answer: a run that has a season is never also\ngiven a container.",block:!0},name:{kind:`Name`,value:`containingMedia`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`SimilarMediaInput`}}},directives:[]}],type:{kind:`NamedType`,name:{kind:`Name`,value:`Media`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`origin`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`OriginInput`}}},directives:[]}],type:{kind:`NamedType`,name:{kind:`Name`,value:`Origin`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`originPage`},arguments:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`input`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`OriginPageInput`}}},directives:[]}],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`OriginPage`}}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`_empty`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]}],directives:[],interfaces:[]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`Origin`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An id to references the origin`,block:!0},name:{kind:`Name`,value:`id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An url to the origin`,block:!0},name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The name of the origin`,block:!0},name:{kind:`Name`,value:`name`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The origin's icon`,block:!0},name:{kind:`Name`,value:`icon`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The origin's color`,block:!0},name:{kind:`Name`,value:`color`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`If the origin is an api only origin`,block:!0},name:{kind:`Name`,value:`isApiOnly`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Boolean`}}},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`OriginInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`id`},type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`ID`}}},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`OriginFilter`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`IS_API_ONLY`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`IS_NOT_API_ONLY`},directives:[]}]},{kind:`InputObjectTypeDefinition`,name:{kind:`Name`,value:`OriginPageInput`},directives:[],fields:[{kind:`InputValueDefinition`,name:{kind:`Name`,value:`ids`},type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`ID`}}}}},directives:[]},{kind:`InputValueDefinition`,name:{kind:`Name`,value:`filters`},type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`OriginFilter`}}}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`OriginPage`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The current page`,block:!0},name:{kind:`Name`,value:`firstPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The current page`,block:!0},name:{kind:`Name`,value:`previousPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The current page`,block:!0},name:{kind:`Name`,value:`currentPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The first page`,block:!0},name:{kind:`Name`,value:`nextPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The last page cursor`,block:!0},name:{kind:`Name`,value:`lastPageCursor`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Id`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Total number of items on the current page`,block:!0},name:{kind:`Name`,value:`currentPageNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The total number of items. Note: This value is not guaranteed to be accurate, do not rely on this for logic`,block:!0},name:{kind:`Name`,value:`totalNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Total number of items before the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic`,block:!0},name:{kind:`Name`,value:`beforeCurrentPageNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`Total number of items after the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic`,block:!0},name:{kind:`Name`,value:`afterCurrentPageNodeCount`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Int`}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`The media page nodes`,block:!0},name:{kind:`Name`,value:`nodes`},arguments:[],type:{kind:`NonNullType`,type:{kind:`ListType`,type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Origin`}}}}},directives:[]}]},{kind:`EnumTypeDefinition`,name:{kind:`Name`,value:`PlaybackSourceType`},directives:[],values:[{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`IFRAME`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`CUSTOM`},directives:[]},{kind:`EnumValueDefinition`,name:{kind:`Name`,value:`OTHER`},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`PlaybackSource`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"Uri consists of the `origin` and `id` fields in the format `origin:id`",block:!0},name:{kind:`Name`,value:`uri`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:"String that is used to target a specific origin, e.g `google` or `yt` for youtube",block:!0},name:{kind:`Name`,value:`origin`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An id that references a specific resource within the origin space`,block:!0},name:{kind:`Name`,value:`id`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`An url to the media resource`,block:!0},name:{kind:`Name`,value:`url`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`type`},arguments:[],type:{kind:`NonNullType`,type:{kind:`NamedType`,name:{kind:`Name`,value:`PlaybackSourceType`}}},directives:[]},{kind:`FieldDefinition`,description:{kind:`StringValue`,value:`JSON data for custom players`,block:!0},name:{kind:`Name`,value:`data`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`JSON`}},directives:[]},{kind:`FieldDefinition`,name:{kind:`Name`,value:`Episode`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`Episode`}},directives:[]}]},{kind:`ScalarTypeDefinition`,name:{kind:`Name`,value:`JSON`},directives:[]},{kind:`ScalarTypeDefinition`,name:{kind:`Name`,value:`Id`},directives:[]},{kind:`ScalarTypeDefinition`,name:{kind:`Name`,value:`Date`},directives:[]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`Query`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`_empty`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]}]},{kind:`ObjectTypeDefinition`,name:{kind:`Name`,value:`Mutation`},interfaces:[],directives:[],fields:[{kind:`FieldDefinition`,name:{kind:`Name`,value:`_empty`},arguments:[],type:{kind:`NamedType`,name:{kind:`Name`,value:`String`}},directives:[]}]},{kind:`SchemaDefinition`,directives:[],operationTypes:[{kind:`OperationTypeDefinition`,operation:`query`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Query`}}},{kind:`OperationTypeDefinition`,operation:`mutation`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Mutation`}}},{kind:`OperationTypeDefinition`,operation:`subscription`,type:{kind:`NamedType`,name:{kind:`Name`,value:`Subscription`}}}]}]};var Rv=`scalar JSON
256
+ scalar Id
257
+ scalar Date
258
+
259
+ type Query {
260
+ _empty: String
261
+ }
262
+
263
+ type Mutation {
264
+ _empty: String
265
+ }
266
+
267
+ type Subscription {
268
+ _empty: String
269
+ }
270
+
271
+ schema {
272
+ query: Query
273
+ mutation: Mutation
274
+ subscription: Subscription
275
+ }
276
+ `,zv=`
277
+ enum MediaType {
278
+ TV
279
+ """
280
+ A televised run of very short episodes. Its own member rather than a TV with a small \`episodeCount\`,
281
+ because AniList publishes the distinction and a viewer filtering for shorts is asking for exactly it.
282
+
283
+ ONLY ANILIST EVER EMITS IT, and AniList loses \`type\` to jikan, which scores 0.9 against 0.8 and
284
+ spells the same show TV. So a short jikan also carries profiles as TV in the aggregate and answers a
285
+ TV filter rather than a TV_SHORT one. That is a known subset, not a bug to work around here: making
286
+ it exact means changing which source wins \`type\`, and that precedence is what keeps a stale dump from
287
+ overwriting a live catalogue (store/aggregate.ts:203, sources/offline/normalize.ts:19-31).
288
+
289
+ INVISIBLE TO THE MERGE, and that takes real code rather than an omission. \`mergeType\` in
290
+ store/fuzzy-merge.ts folds it back to TV before a cluster is profiled, because every gate in that
291
+ file was calibrated on a corpus where AniList's shorts arrived spelled TV. Reading the new member
292
+ there would move two profiles at once on a cluster AniList alone types, and an empty work-kind set
293
+ disables the companion-content veto outright.
294
+ """
295
+ TV_SHORT
296
+ MOVIE
297
+ ANIME
298
+ """Special episodes that have been included in DVD/Blu-ray releases, picture dramas, pilots, etc"""
299
+ SPECIAL
300
+ """(Original Video Animation) Anime that have been released directly on
301
+ DVD/Blu-ray without originally going through a theatrical release or
302
+ television broadcast"""
303
+ OVA
304
+ """(Original Net Animation) Anime that have been originally released online or are only available through streaming services."""
305
+ ONA
306
+ """Live action media such as movies or TV show"""
307
+ LIVE_ACTION
308
+ }
309
+
310
+ enum MediaStatus {
311
+ """Has completed and is no longer being released"""
312
+ FINISHED
313
+ """Currently releasing"""
314
+ RELEASING
315
+ """To be released at a later date"""
316
+ NOT_YET_RELEASED
317
+ """Ended before the work could be finished"""
318
+ CANCELLED
319
+ """Is currently paused from releasing and will resume at a later date"""
320
+ HIATUS
321
+ }
322
+
323
+ """
324
+ The broadcast season a run aired in.
325
+
326
+ Named by the SOURCE, never derived from \`startDate\` here. Seven extractors coerce a bare year into
327
+ January 1 and two answer YYYY-MM-01 for a month-only date (see \`namesADay\` in sources/season.ts), so
328
+ deriving a season from a start date would file every year-only row under WINTER.
329
+ """
330
+ enum MediaSeason {
331
+ WINTER
332
+ SPRING
333
+ SUMMER
334
+ FALL
335
+ }
336
+
337
+ """Broad content category. A media can belong to several (e.g. an anime film is ANIME + MOVIE)."""
338
+ enum MediaCategory {
339
+ ANIME
340
+ """An episodic series (TV / live-action / web)."""
341
+ SERIES
342
+ MOVIE
343
+ }
344
+
345
+ """
346
+ What a handle asserts about the media carrying it. STRUCTURAL only: identity and containment.
347
+
348
+ Narrative relations between different works (prequel, sequel, adaptation, side story) are a SEPARATE
349
+ axis and will get their own \`MediaRelation\` enum on their own field. They are deliberately not mixed:
350
+ PREQUEL says nothing about whether two rows are the same media, and SAME_AS says nothing about story
351
+ order. One enum spanning both would mean neither.
352
+ """
353
+ enum MediaHandleRelation {
354
+ """
355
+ The handle names THIS run. The only relation that unions clusters, in \`upsertMedia\`, and the union
356
+ has NO INVERSE: once two media are welded they stay welded for the session.
357
+
358
+ Minting this for an id that names a SHOW is the single most expensive mistake available here. It
359
+ merged three Mushoku Tensei seasons, four Demon Slayer films and fifteen Dragon Ball Z films, each
360
+ time because one id was the only thing a source could offer and the only relation was this one.
361
+ """
362
+ SAME_AS
363
+ """
364
+ This media is one PART of what the handle names: a run of that show, a film published under that
365
+ series, a season of that title.
366
+
367
+ It carries the handle's url WITHOUT claiming to be it, so a show-level id is worth keeping instead
368
+ of being dropped. It never unions, so no number of these can weld two runs together. What it costs
369
+ is that nothing may read episodes, titles, covers or any other metadata across it: the thing on the
370
+ other end is a bigger thing, and its episode list is every run's at once.
371
+ """
372
+ PART_OF
373
+ """
374
+ This media HOLDS what the handle names: a season of this run, a part of this compilation, a range
375
+ of episodes another packaging carries. The inverse direction of \`PART_OF\`, and it unions nothing.
376
+
377
+ A run's page lists the catalogue seasons that hold it, a run split across seasons lists them all,
378
+ and a container page lists its own seasons. It renders as a LINK and never as a button: the badge
379
+ reader takes "SAME_AS first then anything" and playback takes SAME_AS only, so nothing here can
380
+ place a play button on a row the store has not proven.
381
+ """
382
+ INCLUDES
383
+ }
384
+
385
+ """
386
+ Which PAGE a row draws, as distinct from which identity space it lives in.
387
+
388
+ \`MediaScope\` answers "what does SAME_AS mean here"; this answers "what does this page look like". A
389
+ \`FOLD\` is a catalogue season whose every member is a part or an inclusion of some run: it draws its
390
+ OWN rows in its OWN numbering rather than following to the run, which is what a bookmark on such a
391
+ season has to open. \`RUN\` and \`CONTAINER\` mean what they mean on \`MediaScope\`.
392
+ """
393
+ enum MediaKind {
394
+ RUN
395
+ CONTAINER
396
+ FOLD
397
+ }
398
+
399
+ """
400
+ Which kind of thing a row names, and so which identity space its SAME_AS claims union in.
401
+
402
+ Sameness is only ever asserted within one scope. A claim that crosses scopes is read as PART_OF,
403
+ whatever the producer asked for: a run is part of its show, never the same thing as it.
404
+ """
405
+ enum MediaScope {
406
+ """One broadcast run: a cour, a film. The unit this store aggregates and the unit a card shows."""
407
+ RUN
408
+ """A show, a series, a franchise page: something several runs are part of."""
409
+ CONTAINER
410
+ }
411
+
412
+ """
413
+ How one work relates to another as a STORY. The other axis, and never mixed with \`MediaHandleRelation\`.
414
+
415
+ That enum answers "are these the same thing", this one answers "how does this story connect to that
416
+ one", and the schema has kept them apart deliberately since the handle enum was written: PREQUEL says
417
+ nothing about sameness and SAME_AS says nothing about story order. Nothing here may ever union a
418
+ cluster. A sequel is a DIFFERENT work, and treating one as the same row is the mistake that merged
419
+ three Mushoku Tensei seasons when it was made with SAME_AS.
420
+
421
+ The values are AniList's set (\`relationType(version: 2)\`), which is the widest of the vocabularies in
422
+ play and the one MyAnimeList's own relation names map into without inventing anything. Confirmed
423
+ against live data 2026-09-08: anilist 108465 answers SOURCE, ALTERNATIVE and SEQUEL.
424
+ """
425
+ enum MediaRelation {
426
+ """This work adapts the other, which is usually the manga or novel it came from."""
427
+ ADAPTATION
428
+ """The other work comes first in the story."""
429
+ PREQUEL
430
+ """The other work comes after."""
431
+ SEQUEL
432
+ """The other work is the parent story this one hangs off."""
433
+ PARENT
434
+ """A story beside the main one rather than before or after it."""
435
+ SIDE_STORY
436
+ """The other work follows a character out of this one."""
437
+ CHARACTER
438
+ """A recap or digest of the other work."""
439
+ SUMMARY
440
+ """A different telling of the same story."""
441
+ ALTERNATIVE
442
+ """A work spun out of this one, sharing a world rather than a plot."""
443
+ SPIN_OFF
444
+ """The material this work was adapted FROM. The inverse of ADAPTATION."""
445
+ SOURCE
446
+ """Several works collected into one release."""
447
+ COMPILATION
448
+ """This work contains the other."""
449
+ CONTAINS
450
+ """Related, in a way the source did not name."""
451
+ OTHER
452
+ }
453
+
454
+ """
455
+ One narrative edge out of a media: what it relates to, and how.
456
+
457
+ The node is a SNAPSHOT and not necessarily a row this store has ever fetched. A franchise runs to
458
+ dozens of entries and resolving each before anything could render would make one modal cost dozens of
459
+ requests, so the edge carries what a card and a graph node need (uri, titles, format, status, cover,
460
+ episode count, start date) and nothing else is promised. Opening one navigates to its uri, and the
461
+ store fills that row in properly at that point.
462
+
463
+ Same shape as \`MediaHandle\` on purpose, so the same components render both.
464
+ """
465
+ type MediaRelationEdge {
466
+ """What this edge claims about the story. Never about identity."""
467
+ relation: MediaRelation!
468
+ """The related work, as much of it as the naming source supplied."""
469
+ node: Media!
470
+ """
471
+ What KIND of work the other end is, in the naming source's own words: \`TV\`, \`MOVIE\`, \`MANGA\`,
472
+ \`NOVEL\`, \`ONE_SHOT\`.
473
+
474
+ A string, and on the EDGE rather than on the node, for one reason: \`MediaType\` is anime formats
475
+ only, and a franchise's relations are mostly NOT anime. The novel a show adapts is the single most
476
+ useful relation there is and it cannot be spelled in that enum. Widening \`MediaType\` to hold it
477
+ would reach \`mergeType\` in store/fuzzy-merge.ts and every filter built on it, to carry something
478
+ only ever displayed; the enum's own comment records what moving it costs.
479
+
480
+ DISPLAY ONLY. Nothing may branch on it.
481
+ """
482
+ format: String
483
+ }
484
+
485
+ """
486
+ One work in a franchise graph, thin enough that a whole series fits in one payload.
487
+ """
488
+ type MediaFranchiseNode {
489
+ """What a click navigates to. Also the id the edges below join on."""
490
+ uri: String!
491
+ titles: [MediaTitle!]!
492
+ covers: [MediaCover!]!
493
+ """The naming source's own word for the kind of work. Display only, as on \`MediaRelationEdge\`."""
494
+ format: String
495
+ status: MediaStatus
496
+ episodeCount: Int
497
+ startDate: Date
498
+ }
499
+
500
+ """One arrow in a franchise graph, joining two \`MediaFranchiseNode\` uris."""
501
+ type MediaFranchiseEdge {
502
+ from: String!
503
+ to: String!
504
+ relation: MediaRelation!
505
+ }
506
+
507
+ """
508
+ Every work in one series, and how they connect: the whole graph rather than one media's own edges.
509
+
510
+ WHY IT IS NOT JUST \`relations\` WALKED. Following every edge leaks out of the franchise entirely. A
511
+ crossover promotional short relates BY CHARACTER to each series taking part, so two hops out of
512
+ \`That Time I Got Reincarnated as a Slime\` reaches Attack on Titan, Fire Force, Chihayafuru and seven
513
+ other unrelated shows. Measured 2026-09-08 against live AniList: following every edge reached 36
514
+ works of which 10 were off-franchise, while following only the STORY edges reached 21 works and none.
515
+
516
+ So CHARACTER and OTHER are reported as relations and never TRAVERSED. They answer "who appears in
517
+ this" and "these are connected somehow", neither of which is "this is the same series".
518
+ """
519
+ type MediaFranchise {
520
+ nodes: [MediaFranchiseNode!]!
521
+ edges: [MediaFranchiseEdge!]!
522
+ }
523
+
524
+ """One edge out of a media: which row, and what the edge claims about it."""
525
+ type MediaHandle {
526
+ """The related row. Carries its own uri, origin, id and url."""
527
+ node: Media!
528
+ """What this edge asserts. Only SAME_AS unions clusters."""
529
+ relation: MediaHandleRelation!
530
+ """
531
+ Where this handle came from, when it did not come from the source's own data.
532
+
533
+ Unset, which is every handle a resolver builds out of its own payload, means the source's own
534
+ statement and the store consumes it. \`address\` means the handle was rebuilt from the asked
535
+ aggregated uri by \`buildHandlesFromUri\` (\`src/sources/utils.ts\`): the address names WHICH sources to
536
+ ask and asserts nothing about how the rows relate, so such a claim routes a re-ask and enters no
537
+ cluster. No other value is defined; an unknown one reads as unset.
538
+ """
539
+ provenance: String
540
+ """
541
+ WHY this handle is here, in the deriving rule's own word: \`member\`, \`placeholder\`, or the reason a
542
+ containment link carried (\`asserted\`, \`span\`, \`contested\`, \`prefix\`). Null on a handle no plugin
543
+ derived. Display and diagnosis only; nothing may branch on it.
544
+ """
545
+ via: String
546
+ """Which plugin put it here, e.g. \`plugin:aggregate\`. Null outside the graph store."""
547
+ by: String
548
+ }
549
+
550
+ """
551
+ Where ONE field of an aggregated media got its value, and under which rule.
552
+
553
+ Read by the trace panel, so a wrong field is a question with an answer instead of a screenshot. A
554
+ per-field rule names one \`uri\`; a vote names every \`uris\` that backed it with the deciding \`tier\` and
555
+ its \`witnesses\`. \`answerSeq\` is the supplying member's \`fieldSeq[field]\`, which is the exact answer
556
+ behind the value.
557
+ """
558
+ type MediaFieldProvenance {
559
+ field: String!
560
+ uri: String
561
+ uris: [String!]
562
+ answerSeq: Int
563
+ tier: Float
564
+ witnesses: Int
565
+ rule: String!
566
+ }
567
+
568
+ """
569
+ One rule the store evaluated over the whole graph that this media's cluster does not satisfy.
570
+
571
+ Reported, never repaired: an anomaly is a statement about the sources disagreeing, and hiding it
572
+ would make the disagreement look like a decision.
573
+ """
574
+ type MediaAnomaly {
575
+ rule: String!
576
+ detail: String!
577
+ }
578
+
579
+ type Media {
580
+ """Stable unique identifier that persists across URI changes and source additions"""
581
+ _id: String!
582
+ """Uri consists of the \`origin\` and \`id\` fields in the format \`origin:id\`"""
583
+ uri: String!
584
+ """String that is used to target a specific origin, e.g \`google\` or \`yt\` for youtube"""
585
+ origin: String!
586
+ """An id that references a specific resource within the origin space"""
587
+ id: String!
588
+ """An url to the media resource"""
589
+ url: String
590
+ """
591
+ Every other row this media is related to, and what each relation actually claims.
592
+
593
+ Was \`[Media!]!\`, a bare list, which forced one relation on everything: a handle either asserted
594
+ sameness or did not exist. That is why a source holding only a show-level id had to choose between
595
+ lying and staying silent, and why \`worker/store/db.ts\` had to special-case IMDb out of the graph
596
+ entirely rather than carry its link.
597
+ """
598
+ handles: [MediaHandle!]!
599
+ """
600
+ Every work this one is related to as a STORY: prequels, sequels, the novel it adapts, side stories.
601
+
602
+ Separate from \`handles\`, which is about identity. See \`MediaRelation\`. Empty rather than null when a
603
+ source named none, which is most of them: only AniList supplies these today.
604
+ """
605
+ relations: [MediaRelationEdge!]!
606
+ """
607
+ The whole series this work belongs to, as a graph. Null where no source could supply one, which is
608
+ most of them. NULLABLE deliberately: a non-null list that a source omits nulls the media carrying
609
+ it, taking the rest of the payload with it.
610
+ """
611
+ franchise: MediaFranchise
612
+ """Which identity space this row lives in. An absent value reads as RUN."""
613
+ scope: MediaScope
614
+ """
615
+ Which page this row draws (\`MediaKind\`). Null from a store that does not compute it, which reads as
616
+ \`scope\`.
617
+ """
618
+ kind: MediaKind
619
+ """
620
+ Which member supplied each field, and under which rule. Null from a store that records none.
621
+
622
+ NULLABLE on purpose, like \`franchise\`: a non-null list absent from a payload nulls the media
623
+ carrying it, and a listing card records no provenance.
624
+ """
625
+ provenance: [MediaFieldProvenance!]
626
+ """Every anomaly the store filed against this row's cluster. Null where none were evaluated."""
627
+ anomalies: [MediaAnomaly!]
628
+ score: Float
629
+ titles: [MediaTitle!]!
630
+ type: MediaType
631
+ """Broad categories this media belongs to (anime / series / movie); can be several."""
632
+ categories: [MediaCategory!]!
633
+ status: MediaStatus
634
+ shortDescriptions(input: MediaShortDescriptionInput): [MediaShortDescription!]!
635
+ descriptions(input: MediaDescriptionInput): [MediaDescription!]!
636
+ trailers: [MediaTrailer!]!
637
+ covers: [MediaCover!]!
638
+ banners: [MediaBanner!]!
639
+ averageScore: Int
640
+ popularity: Int
641
+ startDate: Date
642
+ endDate: Date
643
+ isAdult: Boolean
644
+ episodeCount: Int
645
+ """
646
+ The soonest episode a source has scheduled that has not aired yet, or null.
647
+
648
+ Derived from AniList's airing schedule, which was already fetched for \`startDate\`, so it costs no
649
+ request. Null means "nobody scheduled anything ahead of now", which covers a finished run and a
650
+ source that publishes no schedule alike: it is not a promise that the run has ended.
651
+ """
652
+ nextAiringEpisode: MediaAiringEpisode
653
+ """The broadcast season this run aired in, as the source named it."""
654
+ season: MediaSeason
655
+ """
656
+ The calendar year \`season\` belongs to.
657
+
658
+ Separate from \`startDate\` because it survives a coerced date: a source that only knows the year
659
+ still files the run under the right season when another source names one, and a January premiere
660
+ stays in the WINTER of its own year rather than the FALL of the year before.
661
+ """
662
+ seasonYear: Int
663
+ """
664
+ Broad content descriptors, deduplicated across the cluster, richest source first.
665
+
666
+ Free-form strings rather than an enum because no two catalogues agree on a fixed set, and an enum
667
+ would have to drop every value it had not anticipated. Supplied by AniList and jikan; the bundled
668
+ offline catalogue publishes none, so a genre filter cannot be answered during an upstream outage.
669
+ """
670
+ genres: [String!]!
671
+ """
672
+ Finer-grained descriptors than \`genres\`, from AniList's own tag vocabulary.
673
+
674
+ Kept apart from genres rather than merged into one list because AniList publishes them separately
675
+ and its own browse UI groups them separately, so a merged list could not reproduce either. Tags
676
+ AniList marks as a spoiler are dropped at the source and never reach here.
677
+ """
678
+ tags: [String!]!
679
+ episodes: [Episode!]!
680
+ }
681
+
682
+ type MediaTitle {
683
+ language: String!
684
+ title: String!
685
+ score: Float
686
+ }
687
+
688
+ input MediaShortDescriptionInput {
689
+ type: MediaDescriptionContentType = TEXT
690
+ count: Int
691
+ }
692
+
693
+ type MediaShortDescription {
694
+ language: String!
695
+ shortDescription: String!
696
+ score: Float
697
+ }
698
+
699
+ enum MediaDescriptionContentType {
700
+ HTML
701
+ TEXT
702
+ }
703
+
704
+ input MediaDescriptionInput {
705
+ type: MediaDescriptionContentType = TEXT
706
+ count: Int
707
+ }
708
+
709
+ type MediaDescription {
710
+ language: String!
711
+ description: String!
712
+ score: Float
713
+ }
714
+
715
+ type MediaTrailer {
716
+ """Uri consists of the \`origin\` and \`id\` fields in the format \`origin:id\`"""
717
+ uri: String!
718
+ """String that is used to target a specific origin, e.g \`google\` or \`yt\` for youtube"""
719
+ origin: String!
720
+ """An id that references a specific resource within the origin space"""
721
+ id: String!
722
+ """An url to the media resource"""
723
+ url: String
724
+ language: String
725
+ thumbnail: String
726
+ }
727
+
728
+ type MediaAiringEpisode {
729
+ """Which episode of the run this is, as the source numbers it."""
730
+ episodeNumber: Int!
731
+ """When it airs."""
732
+ airingAt: Date!
733
+ }
734
+
735
+ type MediaCover {
736
+ language: String
737
+ url: String!
738
+ height: Int
739
+ width: Int
740
+ """Average #hex color of cover image"""
741
+ color: String
742
+ score: Float
743
+ }
744
+
745
+ type MediaBanner {
746
+ language: String
747
+ url: String!
748
+ height: Int
749
+ width: Int
750
+ """Average #hex color of cover image"""
751
+ color: String
752
+ score: Float
753
+ }
754
+
755
+ """
756
+ What the app asked for at the TOP of the call, so a source can tell a detail view from a listing.
757
+
758
+ THE WORKER WRITES THIS. Every field is regenerated from the worker's own registry at each source's
759
+ boundary before the arguments are coerced, so a value supplied by a caller is replaced rather than
760
+ trusted, and only \`token\` is ever read off the wire. Nullable because the app's own documents send
761
+ none: they are validated by the app-level server before the fan-out that stamps them runs.
762
+ """
763
+ input RequestContext {
764
+ """Identifies THIS hop to the worker. The only field read back off the wire."""
765
+ token: ID!
766
+ """Stable for the whole call tree, so a source may memoize per root rather than per hop."""
767
+ rootId: ID!
768
+ operation: RootOperation!
769
+ """The origins already on the stack, nearest last. A source seeing itself here is in a cycle."""
770
+ chain: [String!]!
771
+ }
772
+
773
+ enum RootOperation {
774
+ MEDIA
775
+ MEDIA_PAGE
776
+ SIMILAR_MEDIA
777
+ }
778
+
779
+ input MediaInput {
780
+ uri: ID
781
+ context: RequestContext
782
+ }
783
+
784
+ """
785
+ How a page is ordered. A bare member sorts ASCENDING and its \`_DESC\` twin descending, the reading the
786
+ suffix carries in every enum of this shape, AniList's \`MediaSort\` included, which these two members
787
+ are borrowed from. A media the sources give no value for sorts LAST in both directions.
788
+
789
+ Naming more than one member runs them in order and the last one decides.
790
+ """
791
+ enum MediaSort {
792
+ """Least popular first."""
793
+ POPULARITY
794
+ """Most popular first. What the home row and the search page ask for."""
795
+ POPULARITY_DESC
796
+ }
797
+
798
+ input MediaPageInput {
799
+ context: RequestContext
800
+ """Filter by media IDs"""
801
+ nodes: [MediaInput!]
802
+ """Filter by search terms"""
803
+ search: String
804
+ """Filter by the media's current release status"""
805
+ status: MediaStatus
806
+ """Filter by category (anime / series / movie); media matching ANY of these are kept."""
807
+ categories: [MediaCategory!]
808
+ """Filter by format; media whose \`type\` is ANY of these are kept. A media with no type is dropped."""
809
+ formats: [MediaType!]
810
+ """
811
+ Filter by broadcast season. Pair it with \`seasonYear\` to name one season rather than every WINTER.
812
+
813
+ A source that can answer a season directly is asked for THIS one instead of the clock's; a source
814
+ that cannot answers nothing rather than answering the current season, which would look like a
815
+ result set and be the wrong year.
816
+ """
817
+ season: MediaSeason
818
+ """Filter by the year of \`season\`."""
819
+ seasonYear: Int
820
+ """Filter by genre; media carrying ALL of these are kept, compared case-insensitively."""
821
+ genres: [String!]
822
+ """Filter by tag; media carrying ALL of these are kept, compared case-insensitively."""
823
+ tags: [String!]
824
+
825
+ sorts: [MediaSort!]
826
+
827
+ """Filter by the start date of the media"""
828
+ startDate: Date
829
+ """Filter by the end date of the media"""
830
+ endDate: Date
831
+
832
+ """Cursor from where to start"""
833
+ at: Id
834
+ """How many pages before the cursor to return"""
835
+ before: Int
836
+ """How many pages after the cursor to return"""
837
+ after: Int
838
+ }
839
+
840
+ type MediaPage {
841
+ """The current page"""
842
+ firstPageCursor: Id
843
+ """The current page"""
844
+ previousPageCursor: Id
845
+ """The current page"""
846
+ currentPageCursor: Id
847
+ """The first page"""
848
+ nextPageCursor: Id
849
+ """The last page cursor"""
850
+ lastPageCursor: Id
851
+ """Total number of items on the current page"""
852
+ currentPageNodeCount: Int
853
+ """The total number of items. Note: This value is not guaranteed to be accurate, do not rely on this for logic"""
854
+ totalNodeCount: Int
855
+ """Total number of items before the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic"""
856
+ beforeCurrentPageNodeCount: Int
857
+ """Total number of items after the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic"""
858
+ afterCurrentPageNodeCount: Int
859
+ """The media page nodes"""
860
+ nodes: [Media!]!
861
+ }
862
+
863
+ """
864
+ The run a caller is looking for, described by EVIDENCE about its own run and never by a season number.
865
+
866
+ Stub models a broadcast run; every catalogue models a show with seasons hanging off it, and no two
867
+ catalogues number those seasons the same way. Netflix folds two cours into one season (its season 2 of
868
+ Mushoku Tensei is 25 episodes over anime's 13 and 12), JustWatch numbers by its own list, anime metadata
869
+ says "Season 2 Part 2". Two numberings in one id space collide: on 2026-09-05 anime season 1 (11
870
+ episodes, no ordinal in its title) took \`nf:80987039-3\` by episode count while season 3 took the same id
871
+ by its ordinal, and \`graph.link\` has no inverse. So a caller holding a show-level id says what it knows
872
+ about ITS run and the owning origin answers with the one run of that show the evidence establishes, or
873
+ with null.
874
+
875
+ What counts as established is decided in ONE place, \`sources/similar.ts\`, and every answering source
876
+ goes through it: a season premiere within 45 days of a day-precise start, episode titles covering most
877
+ of a season, an ordinal every title agrees on with an episode count the season does not exceed, the
878
+ one season dated our year holding no more than our count, or the first season holding our episodes. A
879
+ season holding MORE episodes than the run is a fold of several runs and is never the answer, and a
880
+ season whose length is unknown cannot be shown not to be one. Anything ambiguous is null.
881
+
882
+ The rules decide WHICH season of the show and never WHICH show: \`showId\` settles that, and it came off
883
+ a PART_OF edge whose container cluster a listing's fuzzy title pass may have unioned, so an answer is
884
+ only as right as that union.
885
+ """
886
+ input SimilarMediaInput {
887
+ """The show's id in the ANSWERING origin's own space: a Crunchyroll series id, a Netflix title id, a JustWatch node objectId."""
888
+ showId: ID!
889
+ """When our run started. A date naming a DAY is matched within 45 days; a bare year (\`YYYY-01-01\`) vetoes a season dated another year and, with an episode count on both sides, names the one season dated ours."""
890
+ startDate: Date
891
+ """Every title the caller knows for its run. Read for the season ordinals they agree on, never for the franchise: the show id already settles that."""
892
+ titles: [String!]
893
+ """How many episodes our run has. A season holding more is a fold of several runs and is refused."""
894
+ episodeCount: Int
895
+ """The titles of our run's episodes, when the caller has them. A season most of whose episode titles we carry is ours; one sharing none is not, whatever its number."""
896
+ episodeTitles: [String!]
897
+ context: RequestContext
898
+ }
899
+
900
+ extend type Subscription {
901
+ media(input: MediaInput!): Media
902
+ mediaPage(input: MediaPageInput!): MediaPage!
903
+ """
904
+ The one run of \`showId\` that is the caller's run by the evidence given, or null.
905
+
906
+ The answer is a RUN at the answering origin and carries no handle naming another run: the CALLER
907
+ decides what to claim about it. Null is the expected answer and never an error: no such show, no
908
+ evidence that settles it, or evidence fitting two seasons. Answering with the SHOW here, or with a
909
+ season the evidence merely fails to contradict, recreates the weld the caller asked in order to avoid.
910
+ """
911
+ similarMedia(input: SimilarMediaInput!): Media
912
+ """
913
+ The one run of \`showId\` that HOLDS the caller's run without being it, or null.
914
+
915
+ The other half of the fold, and a SEPARATE FIELD rather than a widened \`similarMedia\` payload: this
916
+ answer means something different about the same evidence, and every source that answers \`similarMedia\`
917
+ today returns \`Media\` from it. A source that cannot tell a container from a run simply never
918
+ implements this one and is asked nothing.
919
+
920
+ Netflix is the worked example. Its season 1 of Mushoku Tensei holds 24 episodes over anime's 11 and
921
+ 12, so \`similarMedia\` refuses it for both runs and is right to: a season longer than the run is not
922
+ the run. It is still where the run is, and this is how the run gets to say so. The answer is the
923
+ CONTAINER SEASON as a run of the answering origin, carrying its own episodes and its own count,
924
+ because a caller claiming \`PART_OF\` from it needs both to place anything on the run.
925
+
926
+ Null is the expected answer and never an error. The evidence is \`pickContainingSeason\` in
927
+ \`src/sources/similar.ts\`, which refuses anything a count alone would have to guess at, and which
928
+ answers nothing at all for a run \`similarMedia\` could answer: a run that has a season is never also
929
+ given a container.
930
+ """
931
+ containingMedia(input: SimilarMediaInput!): Media
932
+ }
933
+ `;function Bv(e,t={skipIntrospection:!0}){let n=Symbol(`hasWrappedResolve`);return{onSchemaChange({schema:r}){let i=r;if(i){for(let r of Object.values(i.getTypeMap()))if((!t.skipIntrospection||!Hn(r))&&j(r))for(let t of Object.values(r.getFields())){if(t[n])continue;let r=t.resolve||ga;t.resolve=(t,n,i,a)=>F(()=>e({root:t,args:n,context:i,info:a,resolver:r,replaceResolver:e=>{r=e}}),e=>typeof e==`function`?F(()=>r(t,n,i,a),t=>Ka(e({result:t,setResult:e=>{t=e}}),()=>t),t=>F(()=>e({result:t,setResult:e=>{t=e}}),()=>{throw t})):r(t,n,i,a)),t[n]=!0}}}}}const Vv=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,Hv=new Set,Uv=typeof process==`object`&&process?process:{},Wv=(e,t,n,r)=>{typeof Uv.emitWarning==`function`?Uv.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)};let Gv=globalThis.AbortController,Kv=globalThis.AbortSignal;if(Gv===void 0){Kv=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},Gv=class{constructor(){t()}signal=new Kv;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=Uv.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,Wv("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}const qv=e=>!Hv.has(e),Jv=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Yv=e=>Jv(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?Xv:null:null;var Xv=class extends Array{constructor(e){super(e),this.fill(0)}},Zv=class e{heap;length;static#e=!1;static create(t){let n=Yv(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Qv=class e{#e;#t;#n;#r;#i;#a;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#s;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;static unsafeExposeInternals(e){return{starts:e.#v,ttls:e.#y,sizes:e.#_,keyMap:e.#c,keyList:e.#l,valList:e.#u,next:e.#d,prev:e.#f,get head(){return e.#p},get tail(){return e.#m},free:e.#h,isBackgroundFetch:t=>e.#L(t),backgroundFetch:(t,n,r,i)=>e.#I(t,n,r,i),moveToTail:t=>e.#z(t),indexes:t=>e.#M(t),rindexes:t=>e.#N(t),isStale:t=>e.#D(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#s}get size(){return this.#o}get fetchMethod(){return this.#i}get memoMethod(){return this.#a}get dispose(){return this.#n}get disposeAfter(){return this.#r}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:f,maxSize:p=0,maxEntrySize:m=0,sizeCalculation:h,fetchMethod:g,memoMethod:_,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:y,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:S}=t;if(n!==0&&!Jv(n))throw TypeError(`max option must be a nonnegative integer`);let C=n?Yv(n):Array;if(!C)throw Error(`invalid max value: `+n);if(this.#e=n,this.#t=p,this.maxEntrySize=m||this.#t,this.sizeCalculation=h,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(_!==void 0&&typeof _!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#a=_,g!==void 0&&typeof g!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#i=g,this.#x=!!g,this.#c=new Map,this.#l=Array(n).fill(void 0),this.#u=Array(n).fill(void 0),this.#d=new C(n),this.#f=new C(n),this.#p=0,this.#m=0,this.#h=Zv.create(n),this.#o=0,this.#s=0,typeof l==`function`&&(this.#n=l),typeof u==`function`?(this.#r=u,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#b=!!this.#n,this.#S=!!this.#r,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!S,this.maxEntrySize!==0){if(this.#t!==0&&!Jv(this.#t))throw TypeError(`maxSize must be a positive integer if specified`);if(!Jv(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#O()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!y,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=Jv(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!Jv(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#C()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t=`LRU_CACHE_UNBOUNDED`;qv(t)&&(Hv.add(t),Wv(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return this.#c.has(e)?1/0:0}#C(){let e=new Xv(this.#e),t=new Xv(this.#e);this.#y=e,this.#v=t,this.#E=(n,r,i=Vv.now())=>{if(t[n]=r===0?0:i,e[n]=r,r!==0&&this.ttlAutopurge){let e=setTimeout(()=>{this.#D(n)&&this.#B(this.#l[n],`expire`)},r+1);e.unref&&e.unref()}},this.#w=n=>{t[n]=e[n]===0?0:Vv.now()},this.#T=(i,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;i.ttl=o,i.start=s,i.now=n||r(),i.remainingTTL=o-(i.now-s)}};let n=0,r=()=>{let e=Vv.now();if(this.ttlResolution>0){n=e;let t=setTimeout(()=>n=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{let a=this.#c.get(i);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((n||r())-s)},this.#D=i=>{let a=t[i],o=e[i];return!!o&&!!a&&(n||r())-a>o}}#w=()=>{};#T=()=>{};#E=()=>{};#D=()=>!1;#O(){let e=new Xv(this.#e);this.#s=0,this.#_=e,this.#k=t=>{this.#s-=e[t],e[t]=0},this.#j=(e,t,n,r)=>{if(this.#L(t))return 0;if(!Jv(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!Jv(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.#A=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#s>n;)this.#F(!0)}this.#s+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#s)}}#k=e=>{};#A=(e,t,n)=>{};#j=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#M({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#m;!(!this.#P(t)||((e||!this.#D(t))&&(yield t),t===this.#p));)t=this.#f[t]}*#N({allowStale:e=this.allowStale}={}){if(this.#o)for(let t=this.#p;!(!this.#P(t)||((e||!this.#D(t))&&(yield t),t===this.#m));)t=this.#d[t]}#P(e){return e!==void 0&&this.#c.get(this.#l[e])===e}*entries(){for(let e of this.#M())this.#u[e]!==void 0&&this.#l[e]!==void 0&&!this.#L(this.#u[e])&&(yield[this.#l[e],this.#u[e]])}*rentries(){for(let e of this.#N())this.#u[e]!==void 0&&this.#l[e]!==void 0&&!this.#L(this.#u[e])&&(yield[this.#l[e],this.#u[e]])}*keys(){for(let e of this.#M()){let t=this.#l[e];t!==void 0&&!this.#L(this.#u[e])&&(yield t)}}*rkeys(){for(let e of this.#N()){let t=this.#l[e];t!==void 0&&!this.#L(this.#u[e])&&(yield t)}}*values(){for(let e of this.#M())this.#u[e]!==void 0&&!this.#L(this.#u[e])&&(yield this.#u[e])}*rvalues(){for(let e of this.#N())this.#u[e]!==void 0&&!this.#L(this.#u[e])&&(yield this.#u[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#M()){let r=this.#u[n],i=this.#L(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#l[n],this))return this.get(this.#l[n],t)}}forEach(e,t=this){for(let n of this.#M()){let r=this.#u[n],i=this.#L(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#l[n],this)}}rforEach(e,t=this){for(let n of this.#N()){let r=this.#u[n],i=this.#L(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#l[n],this)}}purgeStale(){let e=!1;for(let t of this.#N({allowStale:!0}))this.#D(t)&&(this.#B(this.#l[t],`expire`),e=!0);return e}info(e){let t=this.#c.get(e);if(t===void 0)return;let n=this.#u[t],r=this.#L(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#y&&this.#v){let e=this.#y[t],n=this.#v[t];e&&n&&(i.ttl=e-(Vv.now()-n),i.start=Date.now())}return this.#_&&(i.size=this.#_[t]),i}dump(){let e=[];for(let t of this.#M({allowStale:!0})){let n=this.#l[t],r=this.#u[t],i=this.#L(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#y&&this.#v){a.ttl=this.#y[t];let e=Vv.now()-this.#v[t];a.start=Math.floor(Date.now()-e)}this.#_&&(a.size=this.#_[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=Vv.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#j(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#B(e,`set`),this;let u=this.#o===0?void 0:this.#c.get(e);if(u===void 0)u=this.#o===0?this.#m:this.#h.length===0?this.#o===this.#e?this.#F(!1):this.#o:this.#h.pop(),this.#l[u]=e,this.#u[u]=t,this.#c.set(e,u),this.#d[this.#m]=u,this.#f[u]=this.#m,this.#m=u,this.#o++,this.#A(u,l,s),s&&(s.set=`add`),c=!1;else{this.#z(u);let n=this.#u[u];if(t!==n){if(this.#x&&this.#L(n)){n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#b&&this.#n?.(t,e,`set`),this.#S&&this.#g?.push([t,e,`set`]))}else a||(this.#b&&this.#n?.(n,e,`set`),this.#S&&this.#g?.push([n,e,`set`]));if(this.#k(u),this.#A(u,l,s),this.#u[u]=t,s){s.set=`replace`;let e=n&&this.#L(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`)}if(r!==0&&!this.#y&&this.#C(),this.#y&&(c||this.#E(u,r,i),s&&this.#T(s,u)),!a&&this.#S&&this.#g){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}return this}pop(){try{for(;this.#o;){let e=this.#u[this.#p];if(this.#F(!0),this.#L(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#S&&this.#g){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}}}#F(e){let t=this.#p,n=this.#l[t],r=this.#u[t];return this.#x&&this.#L(r)?r.__abortController.abort(Error(`evicted`)):(this.#b||this.#S)&&(this.#b&&this.#n?.(r,n,`evict`),this.#S&&this.#g?.push([r,n,`evict`])),this.#k(t),e&&(this.#l[t]=void 0,this.#u[t]=void 0,this.#h.push(t)),this.#o===1?(this.#p=this.#m=0,this.#h.length=0):this.#p=this.#d[t],this.#c.delete(n),this.#o--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#c.get(e);if(i!==void 0){let e=this.#u[i];if(this.#L(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#D(i))r&&(r.has=`stale`,this.#T(r,i));else return n&&this.#w(i),r&&(r.has=`hit`,this.#T(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#c.get(e);if(r===void 0||!n&&this.#D(r))return;let i=this.#u[r];return this.#L(i)?i.__staleWhileFetching:i}#I(e,t,n,r){let i=t===void 0?void 0:this.#u[t];if(this.#L(i))return i;let a=new Gv,{signal:o}=n;o?.addEventListener(`abort`,()=>a.abort(o.reason),{signal:a.signal});let s={signal:a.signal,options:n,context:r},c=(r,i=!1)=>{let{aborted:o}=a.signal,c=n.ignoreFetchAbort&&r!==void 0;if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(a.signal.reason);let l=f;return this.#u[t]===f&&(r===void 0?l.__staleWhileFetching?this.#u[t]=l.__staleWhileFetching:this.#B(e,`fetch`):(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,s.options))),r},l=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e)),u=r=>{let{aborted:i}=a.signal,o=i&&n.allowStaleOnFetchAbort,s=o||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection,l=f;if(this.#u[t]===f&&(!c||l.__staleWhileFetching===void 0?this.#B(e,`fetch`):o||(this.#u[t]=l.__staleWhileFetching)),s)return n.status&&l.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw r},d=(t,r)=>{let o=this.#i?.(e,i,s);o&&o instanceof Promise&&o.then(e=>t(e===void 0?void 0:e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(c,l),p=Object.assign(f,{__abortController:a,__staleWhileFetching:i,__returned:void 0});return t===void 0?(this.set(e,p,{...s.options,status:void 0}),t=this.#c.get(e)):this.#u[t]=p,p}#L(e){if(!this.#x)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof Gv}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:_}=t;if(!this.#x)return g&&(g.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:_},y=this.#c.get(e);if(y===void 0){g&&(g.fetch=`miss`);let t=this.#I(e,y,v,m);return t.__returned=t}else{let t=this.#u[y];if(this.#L(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#D(y);if(!h&&!i)return g&&(g.fetch=`hit`),this.#z(y),r&&this.#w(y),g&&this.#T(g,y),t;let a=this.#I(e,y,v,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#a;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#c.get(e);if(o!==void 0){let t=this.#u[o],s=this.#L(t);return a&&this.#T(a,o),this.#D(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#B(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#z(o),r&&this.#w(o),t))}else a&&(a.get=`miss`)}#R(e,t){this.#f[t]=e,this.#d[e]=t}#z(e){e!==this.#m&&(e===this.#p?this.#p=this.#d[e]:this.#R(this.#f[e],this.#d[e]),this.#R(this.#m,e),this.#m=e)}delete(e){return this.#B(e,`delete`)}#B(e,t){let n=!1;if(this.#o!==0){let r=this.#c.get(e);if(r!==void 0)if(n=!0,this.#o===1)this.#V(t);else{this.#k(r);let n=this.#u[r];if(this.#L(n)?n.__abortController.abort(Error(`deleted`)):(this.#b||this.#S)&&(this.#b&&this.#n?.(n,e,t),this.#S&&this.#g?.push([n,e,t])),this.#c.delete(e),this.#l[r]=void 0,this.#u[r]=void 0,r===this.#m)this.#m=this.#f[r];else if(r===this.#p)this.#p=this.#d[r];else{let e=this.#f[r];this.#d[e]=this.#d[r];let t=this.#d[r];this.#f[t]=this.#f[r]}this.#o--,this.#h.push(r)}}if(this.#S&&this.#g?.length){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}return n}clear(){return this.#V(`delete`)}#V(e){for(let t of this.#N({allowStale:!0})){let n=this.#u[t];if(this.#L(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#l[t];this.#b&&this.#n?.(n,r,e),this.#S&&this.#g?.push([n,r,e])}}if(this.#c.clear(),this.#u.fill(void 0),this.#l.fill(void 0),this.#y&&this.#v&&(this.#y.fill(0),this.#v.fill(0)),this.#_&&this.#_.fill(0),this.#p=0,this.#m=0,this.#h.length=0,this.#s=0,this.#o=0,this.#S&&this.#g){let e=this.#g,t;for(;t=e?.shift();)this.#r?.(...t)}}};const $v=e=>{let t=e?.buildEntityId??ey,n=new Qv({max:e?.max??1e3,allowStale:!1,noDisposeOnSet:!0,dispose(e){a(e,!1)}}),r=new Map,i=new Map;function a(e,t=!0){let a=i.get(e);if(a!==void 0){for(let t of a)r.get(t)?.delete(e);i.delete(e)}t&&n.delete(e)}function o(e){let t=r.get(e);if(t!==void 0)for(let e of t)a(e)}return{set(e,a,o,s){n.set(e,a,{ttl:s});let c=new Set;i.set(e,c);for(let{typename:n,id:i}of o){let a=r.get(n);if(a??(a=new Set,r.set(n,a)),a.add(e),c.add(n),i!==void 0){let a=t(n,i),o=r.get(a);o??(o=new Set,r.set(a,o)),o.add(e),c.add(a)}}},get(e){return n.get(e)??null},invalidate(e){for(let{typename:n,id:r}of e)o(r==null?n:t(n,r))}}},ey=(e,t)=>`${e}:${t}`;var ty=s(((e,t)=>{t.exports=function(e,t){t||={},typeof t==`function`&&(t={cmp:t});var n=typeof t.cycles==`boolean`?t.cycles:!1,r=t.cmp&&(function(e){return function(t){return function(n,r){return e({key:n,value:t[n]},{key:r,value:t[r]})}}})(t.cmp),i=[];return(function e(t){if(t&&t.toJSON&&typeof t.toJSON==`function`&&(t=t.toJSON()),t!==void 0){if(typeof t==`number`)return isFinite(t)?``+t:`null`;if(typeof t!=`object`)return JSON.stringify(t);var a,o;if(Array.isArray(t)){for(o=`[`,a=0;a<t.length;a++)a&&(o+=`,`),o+=e(t[a])||`null`;return o+`]`}if(t===null)return`null`;if(i.indexOf(t)!==-1){if(n)return JSON.stringify(`__cycle__`);throw TypeError(`Converting circular structure to JSON`)}var s=i.push(t)-1,c=Object.keys(t).sort(r&&r(t));for(o=``,a=0;a<c.length;a++){var l=c[a],u=e(t[l]);u&&(o&&(o+=`,`),o+=JSON.stringify(l)+`:`+u)}return i.splice(s,1),`{`+o+`}`}})(e)}}));function ny(e){let t=new zd.TextEncoder().encode(e);return F(()=>zd.crypto.subtle.digest({name:`SHA-256`},t),e=>{let t=new Uint8Array(e),n=``;for(let e=0,r=t.length;e<r;e++){let r=t[e].toString(16);n+=`00`.slice(0,Math.max(0,2-r.length))+r}return n})}var ry=u(ty(),1);const iy=e=>ny([e.documentString,e.operationName??``,(0,ry.default)(e.variableValues??{}),e.sessionId??``].join(`|`)),ay=e=>e.result.errors?(console.warn(`[useResponseCache] Failed to cache due to errors`),!1):!0;function oy(e){return Al(e.document,ft)}const sy=oo(function(e,{invalidateViaMutation:t,ttlPerSchemaCoordinate:n},r,i){let a=new mr(r),o;return[lt(e,gr(a,{OperationDefinition:{enter(e){if(!t&&e.operation===`mutation`||e.operation===`subscription`)return!1}},...n!=null&&{Field(e){let t=a.getParentType();if(t){let r=n[`${t.name}.${e.name.value}`];o=dy(r,o)}}},SelectionSet(e,t){let n=a.getParentType(),r=n&&i.get(n.name),o=e.selections.some(e=>e.kind===E.FIELD&&e.name.value===`__typename`&&!e.alias),s=[...e.selections];return o||s.push({kind:E.FIELD,name:{kind:E.NAME,value:`__typename`},alias:{kind:E.NAME,value:`__responseCacheTypeName`}}),r&&(e.selections.some(e=>e.kind===E.FIELD&&e.name.value===r&&!e.alias)||s.push({kind:E.FIELD,name:{kind:E.NAME,value:r},alias:{kind:E.NAME,value:`__responseCacheId`}})),{...e,selections:s}}})),o]});function cy({cache:e=$v(),ttl:t=1/0,session:n,enabled:r,ignoredTypes:i=[],ttlPerType:a={},ttlPerSchemaCoordinate:o={},scopePerSchemaCoordinate:s={},idFields:c=[`id`],invalidateViaMutation:l=!0,buildResponseCacheKey:u=iy,getDocumentString:d=oy,shouldCacheResult:f=ay,onTtl:p,includeExtensionMetadata:m=typeof process<`u`?!!{}.DEBUG:!1}){let h=typeof e==`function`?io(e):()=>e,g=new Set(i),_=new Map;r&&=io(r),o={"Query.__schema":0,...o};let v={queries:{invalidateViaMutation:l,ttlPerSchemaCoordinate:o},mutations:{invalidateViaMutation:l}},y=new Map,b;function x(e,t){return s[e]===`PRIVATE`?!0:Object.keys(t).some(t=>s[`${e}.${t}`]===`PRIVATE`)}return{onSchemaChange({schema:e}){if(b===e)return;b=e;let t=b.getDirective(`cacheControl`);ds(b,{...t&&{[L.COMPOSITE_TYPE]:e=>(uo(b,e,`cacheControl`)?.forEach(t=>{t.maxAge!=null&&(a[e.name]=t.maxAge*1e3),t.scope&&(s[e.name]=t.scope)}),e)},[L.FIELD]:(e,n,r)=>{let i=`${r}.${n}`,a=fy(e.type);return _.set(i,a),c.includes(n)&&!y.has(r)&&y.set(r,n),t&&uo(b,e,`cacheControl`)?.forEach(e=>{e.maxAge!=null&&(o[i]=e.maxAge*1e3),e.scope&&(s[i]=e.scope)}),e}})},onExecute(e){if(r&&!r(e.args.contextValue))return;let i=new Map,o=new Set,s,c=!1,S=n(e.args.contextValue);function C({execute:t,onExecuteDone:n}){let r=!1;return e.setExecuteFn(e=>(r=!0,t(e))),{onExecuteDone(e){return r||console.warn(`[useResponseCache] The cached execute function was not called, another plugin might have overwritten it. Please check your plugin order.`),n?.(e)}}}function w(e,t){if(!c){if(g.has(e.typename)||!S&&x(e.typename,t)){c=!0;return}if(!e.id){let n=y.get(e.typename);n&&(e.id=t[n])}if(o.add(e.typename),e.typename in a){let t=a[e.typename];s=dy(t,s)}e.id!=null&&i.set(`${e.typename}:${e.id}`,e);for(let n in t){let r=t[n];(r==null||Array.isArray(r)&&r.length===0)&&_.get(`${e.typename}.${n}`)?.forEach(e=>{if(e in a){let t=a[e];s=dy(t,s)}i.set(e,{typename:e})})}}}function ee(t,n){let r=!1;t.data&&(t={...t},t.data=py(t.data,w),r=!0);let a=h(e.args.contextValue);if(a==null){console.warn(`[useResponseCache] Cache instance is not available for the context. Skipping invalidation.`);return}if(i.size>0&&(a.invalidate(i.values()),m))return n(uy(t,{invalidatedEntities:Array.from(i.values())}));r&&n(t)}return l!==!1&&_a(e.args.document,e.args.operationName)?.operation===`mutation`?C({execute(t){let[n]=sy(t.document,v.mutations,t.schema,y);return e.executeFn({...t,document:n})},onExecuteDone({result:e,setResult:t}){return Fl(e)?ly(ee):ee(e,t)}}):F(()=>u({documentString:d(e.args),variableValues:e.args.variableValues,operationName:e.args.operationName,sessionId:S,context:e.args.contextValue}),n=>{let r=h(e.args.contextValue);return r??console.warn(`[useResponseCache] Cache instance is not available for the context. Skipping cache lookup.`),F(()=>r.get(n),a=>{if(a!=null)return C({execute:()=>m?uy(a,{hit:!0}):a});function o(a,o){a.data&&=py(a.data,w);let l=s??t;if(p&&(l=p({ttl:l,context:e.args.contextValue})),c||!f({cacheKey:n,result:a})||l===0){m&&o(uy(a,{hit:!1,didCache:!1}));return}r.set(n,a,i.values(),l),m&&o(uy(a,{hit:!1,didCache:!0,ttl:l}))}return C({execute(t){let[n,r]=sy(t.document,v.queries,b,y);return s=r,e.executeFn({...t,document:n})},onExecuteDone({result:e,setResult:t}){return Fl(e)?ly(o):o(e,t)}})})})}}}function ly(e){let t={};return{onNext(n){if(n.result.data&&(t.data=n.result.data),n.result.errors&&(t.errors=n.result.errors),n.result.extensions&&(t.extensions=n.result.extensions),`hasNext`in n.result){let{incremental:r,hasNext:i}=n.result;if(r)for(let e of r)Xs({executionResult:t,incrementalResult:e});i||e(t,n.setResult)}let r={...n.result};r.data&&=py(r.data),`hasNext`in r&&r.incremental&&(r.incremental=r.incremental.map(e=>`items`in e&&e.items?{...e,items:py(e.items)}:`data`in e&&e.data?{...e,data:py(e.data)}:e)),n.setResult(r)}}}function uy(e,t){return{...e,extensions:{...e.extensions,responseCache:{...e.extensions?.responseCache,...t}}}}function dy(e,t){return typeof e==`number`&&!Number.isNaN(e)?typeof t==`number`?Math.min(t,e):e:t}function fy(e){return Dt(e)||M(e)?fy(e.ofType):wt(e)?e.getTypes().map(e=>fy(e)).flat():[e.name]}function py(e,t){if(Array.isArray(e))return e.map(e=>py(e,t));if(typeof e!=`object`||!e)return e;let n=Object.getPrototypeOf(e);if(n!=null&&n!==Object.prototype)return e;e={...e};let r=e.__responseCacheTypeName??e.__typename;if(typeof r==`string`){let n={typename:r};delete e.__responseCacheTypeName,e.__responseCacheId&&(typeof e.__responseCacheId==`string`||typeof e.__responseCacheId==`number`)&&(n.id=e.__responseCacheId,delete e.__responseCacheId),t?.(n,e)}for(let n in e){let r=e[n];Array.isArray(r)&&(e[n]=py(r,t)),typeof r==`object`&&r&&(e[n]=py(r,t))}return e}const my=new WeakMap,hy=new WeakMap;function gy({request:e}){return hy.get(e)}const _y=function({context:e}){let t=my.get(e);if(t==null)throw Error(`[useResponseCache] This plugin is not configured correctly. Make sure you use this plugin with GraphQL Yoga`);return t},vy=e=>e.contextValue.params.query||Al(e.document,ft);function yy(e){let t=e?.buildResponseCacheKey||iy,n=e.cache??by(),r=e.enabled??(()=>!0),i;return{onYogaInit({yoga:e}){i=e.logger},onPluginInit({addPlugin:t}){t(cy({...e,enabled:e=>r(e.request,e),cache:n,getDocumentString:vy,session:gy,buildResponseCacheKey:_y,shouldCacheResult({cacheKey:t,result:n}){let r;if(e.shouldCacheResult?r=e.shouldCacheResult({cacheKey:t,result:n}):(r=!n.errors?.length,r||i.debug(`[useResponseCache] Decided not to cache the response because it contains errors`)),r){let e=n.extensions||={},r=e.http||={},i=r.headers||={};i.ETag=t,i[`Last-Modified`]=new Date().toUTCString()}return r}}))},onRequest({request:e,serverContext:t,fetchAPI:i,endResponse:a}){if(r(e,t)){let t=e.headers.get(`If-None-Match`);if(t)return F(()=>n.get(t),n=>{if(n){let r=e.headers.get(`If-Modified-Since`),o=n.extensions?.http?.headers?.[`Last-Modified`];o!=null&&(r==null||new Date(r).getTime()>=new Date(o).getTime())&&a(new i.Response(null,{status:304,headers:{ETag:t}}))}})}},onParams({params:i,request:a,context:o,setResult:s}){return F(()=>e.session(a,o),c=>F(()=>t({documentString:i.query||``,variableValues:i.variables,operationName:i.operationName,sessionId:c,request:a,context:o}),t=>{if(my.set(o,t),hy.set(a,c),r(a,o))return F(()=>n.get(t),t=>{if(t){let n={...t,[Symbol.for(`servedFromResponseCache`)]:!0};e.includeExtensionMetadata?s(uy(n,{hit:!0})):s(n);return}})}))}}}const by=$v;var xy={NAME:`Name`,DOCUMENT:`Document`,OPERATION_DEFINITION:`OperationDefinition`,VARIABLE_DEFINITION:`VariableDefinition`,SELECTION_SET:`SelectionSet`,FIELD:`Field`,ARGUMENT:`Argument`,FRAGMENT_SPREAD:`FragmentSpread`,INLINE_FRAGMENT:`InlineFragment`,FRAGMENT_DEFINITION:`FragmentDefinition`,VARIABLE:`Variable`,INT:`IntValue`,FLOAT:`FloatValue`,STRING:`StringValue`,BOOLEAN:`BooleanValue`,NULL:`NullValue`,ENUM:`EnumValue`,LIST:`ListValue`,OBJECT:`ObjectValue`,OBJECT_FIELD:`ObjectField`,DIRECTIVE:`Directive`,NAMED_TYPE:`NamedType`,LIST_TYPE:`ListType`,NON_NULL_TYPE:`NonNullType`},Sy=class extends Error{constructor(e,t,n,r,i,a,o){super(e),this.name=`GraphQLError`,this.message=e,i&&(this.path=i),t&&(this.nodes=Array.isArray(t)?t:[t]),n&&(this.source=n),r&&(this.positions=r),a&&(this.originalError=a);var s=o;if(!s&&a){var c=a.extensions;c&&typeof c==`object`&&(s=c)}this.extensions=s||{}}toJSON(){return{...this,message:this.message}}toString(){return this.message}get[Symbol.toStringTag](){return`GraphQLError`}},R,z;function Cy(e){return new Sy(`Syntax Error: Unexpected token at ${z} in ${e}`)}function wy(e){if(e.lastIndex=z,e.test(R))return R.slice(z,z=e.lastIndex)}var Ty=/ +(?=[^\s])/y;function Ey(e){for(var t=e.split(`
934
+ `),n=``,r=0,i=0,a=t.length-1,o=0;o<t.length;o++)Ty.lastIndex=0,Ty.test(t[o])&&(o&&(!r||Ty.lastIndex<r)&&(r=Ty.lastIndex),i||=o,a=o);for(var s=i;s<=a;s++)s!==i&&(n+=`
935
+ `),n+=t[s].slice(r).replace(/\\"""/g,`"""`);return n}function Dy(){for(var e=0|R.charCodeAt(z++);e===9||e===10||e===13||e===32||e===35||e===44||e===65279;e=0|R.charCodeAt(z++))if(e===35)for(;(e=0|R.charCodeAt(z++))&&e!==10&&e!==13;);z--}function Oy(){for(var e=z,t=0|R.charCodeAt(z++);t>=48&&t<=57||t>=65&&t<=90||t===95||t>=97&&t<=122;t=0|R.charCodeAt(z++));if(e===z-1)throw Cy(`Name`);var n=R.slice(e,--z);return Dy(),n}function ky(){return{kind:`Name`,value:Oy()}}var Ay=/(?:"""|(?:[\s\S]*?[^\\])""")/y,jy=/(?:(?:\.\d+)?[eE][+-]?\d+|\.\d+)/y;function My(e){var t;switch(R.charCodeAt(z)){case 91:z++,Dy();for(var n=[];R.charCodeAt(z)!==93;)n.push(My(e));return z++,Dy(),{kind:`ListValue`,values:n};case 123:z++,Dy();for(var r=[];R.charCodeAt(z)!==125;){var i=ky();if(R.charCodeAt(z++)!==58)throw Cy(`ObjectField`);Dy(),r.push({kind:`ObjectField`,name:i,value:My(e)})}return z++,Dy(),{kind:`ObjectValue`,fields:r};case 36:if(e)throw Cy(`Variable`);return z++,{kind:`Variable`,name:ky()};case 34:if(R.charCodeAt(z+1)===34&&R.charCodeAt(z+2)===34){if(z+=3,(t=wy(Ay))==null)throw Cy(`StringValue`);return Dy(),{kind:`StringValue`,value:Ey(t.slice(0,-3)),block:!0}}else{var a=z,o;z++;var s=!1;for(o=0|R.charCodeAt(z++);o===92&&(z++,s=!0)||o!==10&&o!==13&&o!==34&&o;o=0|R.charCodeAt(z++));if(o!==34)throw Cy(`StringValue`);return t=R.slice(a,z),Dy(),{kind:`StringValue`,value:s?JSON.parse(t):t.slice(1,-1),block:!1}}case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:for(var c=z++,l;(l=0|R.charCodeAt(z++))>=48&&l<=57;);var u=R.slice(c,--z);if((l=R.charCodeAt(z))===46||l===69||l===101){if((t=wy(jy))==null)throw Cy(`FloatValue`);return Dy(),{kind:`FloatValue`,value:u+t}}else return Dy(),{kind:`IntValue`,value:u};case 110:if(R.charCodeAt(z+1)===117&&R.charCodeAt(z+2)===108&&R.charCodeAt(z+3)===108)return z+=4,Dy(),{kind:`NullValue`};break;case 116:if(R.charCodeAt(z+1)===114&&R.charCodeAt(z+2)===117&&R.charCodeAt(z+3)===101)return z+=4,Dy(),{kind:`BooleanValue`,value:!0};break;case 102:if(R.charCodeAt(z+1)===97&&R.charCodeAt(z+2)===108&&R.charCodeAt(z+3)===115&&R.charCodeAt(z+4)===101)return z+=5,Dy(),{kind:`BooleanValue`,value:!1};break}return{kind:`EnumValue`,value:Oy()}}function Ny(e){if(R.charCodeAt(z)===40){var t=[];z++,Dy();do{var n=ky();if(R.charCodeAt(z++)!==58)throw Cy(`Argument`);Dy(),t.push({kind:`Argument`,name:n,value:My(e)})}while(R.charCodeAt(z)!==41);return z++,Dy(),t}}function Py(e){if(R.charCodeAt(z)===64){var t=[];do z++,t.push({kind:`Directive`,name:ky(),arguments:Ny(e)});while(R.charCodeAt(z)===64);return t}}function Fy(){for(var e=0;R.charCodeAt(z)===91;)e++,z++,Dy();var t={kind:`NamedType`,name:ky()};do if(R.charCodeAt(z)===33&&(z++,Dy(),t={kind:`NonNullType`,type:t}),e){if(R.charCodeAt(z++)!==93)throw Cy(`NamedType`);Dy(),t={kind:`ListType`,type:t}}while(e--);return t}function Iy(){if(R.charCodeAt(z++)!==123)throw Cy(`SelectionSet`);return Dy(),Ly()}function Ly(){var e=[];do if(R.charCodeAt(z)===46){if(R.charCodeAt(++z)!==46||R.charCodeAt(++z)!==46)throw Cy(`SelectionSet`);switch(z++,Dy(),R.charCodeAt(z)){case 64:e.push({kind:`InlineFragment`,typeCondition:void 0,directives:Py(!1),selectionSet:Iy()});break;case 111:R.charCodeAt(z+1)===110?(z+=2,Dy(),e.push({kind:`InlineFragment`,typeCondition:{kind:`NamedType`,name:ky()},directives:Py(!1),selectionSet:Iy()})):e.push({kind:`FragmentSpread`,name:ky(),directives:Py(!1)});break;case 123:z++,Dy(),e.push({kind:`InlineFragment`,typeCondition:void 0,directives:void 0,selectionSet:Ly()});break;default:e.push({kind:`FragmentSpread`,name:ky(),directives:Py(!1)})}}else{var t=ky(),n=void 0;R.charCodeAt(z)===58&&(z++,Dy(),n=t,t=ky());var r=Ny(!1),i=Py(!1),a=void 0;R.charCodeAt(z)===123&&(z++,Dy(),a=Ly()),e.push({kind:`Field`,alias:n,name:t,arguments:r,directives:i,selectionSet:a})}while(R.charCodeAt(z)!==125);return z++,Dy(),{kind:`SelectionSet`,selections:e}}function Ry(){if(Dy(),R.charCodeAt(z)===40){var e=[];z++,Dy();do{var t=void 0;if(R.charCodeAt(z)===34&&(t=My(!0)),R.charCodeAt(z++)!==36)throw Cy(`Variable`);var n=ky();if(R.charCodeAt(z++)!==58)throw Cy(`VariableDefinition`);Dy();var r=Fy(),i=void 0;R.charCodeAt(z)===61&&(z++,Dy(),i=My(!0)),Dy();var a={kind:`VariableDefinition`,variable:{kind:`Variable`,name:n},type:r,defaultValue:i,directives:Py(!0)};t&&(a.description=t),e.push(a)}while(R.charCodeAt(z)!==41);return z++,Dy(),e}}function zy(e){var t=ky();if(R.charCodeAt(z++)!==111||R.charCodeAt(z++)!==110)throw Cy(`FragmentDefinition`);Dy();var n={kind:`FragmentDefinition`,name:t,typeCondition:{kind:`NamedType`,name:ky()},directives:Py(!1),selectionSet:Iy()};return e&&(n.description=e),n}function By(){var e=[];do{var t=void 0;if(R.charCodeAt(z)===34&&(t=My(!0)),R.charCodeAt(z)===123){if(t)throw Cy(`Document`);z++,Dy(),e.push({kind:`OperationDefinition`,operation:`query`,name:void 0,variableDefinitions:void 0,directives:void 0,selectionSet:Ly()})}else{var n=Oy();switch(n){case`fragment`:e.push(zy(t));break;case`query`:case`mutation`:case`subscription`:var r,i=void 0;(r=R.charCodeAt(z))!==40&&r!==64&&r!==123&&(i=ky());var a={kind:`OperationDefinition`,operation:n,name:i,variableDefinitions:Ry(),directives:Py(!1),selectionSet:Iy()};t&&(a.description=t),e.push(a);break;default:throw Cy(`Document`)}}}while(z<R.length);return e}function Vy(e,t){return R=e.body?e.body:e,z=0,Dy(),t&&t.noLocation?{kind:`Document`,definitions:By()}:{kind:`Document`,definitions:By(),loc:{start:0,end:R.length,startToken:void 0,endToken:void 0,source:{body:R,name:`graphql.web`,locationOffset:{line:1,column:1}}}}}function Hy(e,t,n){for(var r=``,i=0;i<e.length;i++)i&&(r+=t),r+=n(e[i]);return r}function Uy(e){return JSON.stringify(e)}function Wy(e){return`"""
936
+ `+e.replace(/"""/g,`\\"""`)+`
937
+ """`}var Gy=`
938
+ `,Ky={OperationDefinition(e){var t=``;e.description&&(t+=Ky.StringValue(e.description)+`
939
+ `),t+=e.operation,e.name&&(t+=` `+e.name.value),e.variableDefinitions&&e.variableDefinitions.length&&(e.name||(t+=` `),t+=`(`+Hy(e.variableDefinitions,`, `,Ky.VariableDefinition)+`)`),e.directives&&e.directives.length&&(t+=` `+Hy(e.directives,` `,Ky.Directive));var n=Ky.SelectionSet(e.selectionSet);return t===`query`?n:t+` `+n},VariableDefinition(e){var t=``;return e.description&&(t+=Ky.StringValue(e.description)+` `),t+=Ky.Variable(e.variable)+`: `+qy(e.type),e.defaultValue&&(t+=` = `+qy(e.defaultValue)),e.directives&&e.directives.length&&(t+=` `+Hy(e.directives,` `,Ky.Directive)),t},Field(e){var t=e.alias?e.alias.value+`: `+e.name.value:e.name.value;if(e.arguments&&e.arguments.length){var n=Hy(e.arguments,`, `,Ky.Argument);t.length+n.length+2>80?t+=`(`+(Gy+=` `)+Hy(e.arguments,Gy,Ky.Argument)+(Gy=Gy.slice(0,-2))+`)`:t+=`(`+n+`)`}return e.directives&&e.directives.length&&(t+=` `+Hy(e.directives,` `,Ky.Directive)),e.selectionSet&&e.selectionSet.selections.length&&(t+=` `+Ky.SelectionSet(e.selectionSet)),t},StringValue(e){return e.block?Wy(e.value).replace(/\n/g,Gy):Uy(e.value)},BooleanValue:e=>``+e.value,NullValue:e=>`null`,IntValue:e=>e.value,FloatValue:e=>e.value,EnumValue:e=>e.value,Name:e=>e.value,Variable:e=>`$`+e.name.value,ListValue:e=>`[`+Hy(e.values,`, `,qy)+`]`,ObjectValue:e=>`{`+Hy(e.fields,`, `,Ky.ObjectField)+`}`,ObjectField:e=>e.name.value+`: `+qy(e.value),Document(e){return!e.definitions||!e.definitions.length?``:Hy(e.definitions,`
940
+
941
+ `,qy)},SelectionSet:e=>`{`+(Gy+=` `)+Hy(e.selections,Gy,qy)+(Gy=Gy.slice(0,-2))+`}`,Argument:e=>e.name.value+`: `+qy(e.value),FragmentSpread(e){var t=`...`+e.name.value;return e.directives&&e.directives.length&&(t+=` `+Hy(e.directives,` `,Ky.Directive)),t},InlineFragment(e){var t=`...`;return e.typeCondition&&(t+=` on `+e.typeCondition.name.value),e.directives&&e.directives.length&&(t+=` `+Hy(e.directives,` `,Ky.Directive)),t+=` `+Ky.SelectionSet(e.selectionSet)},FragmentDefinition(e){var t=``;return e.description&&(t+=Ky.StringValue(e.description)+`
942
+ `),t+=`fragment `+e.name.value,t+=` on `+e.typeCondition.name.value,e.directives&&e.directives.length&&(t+=` `+Hy(e.directives,` `,Ky.Directive)),t+` `+Ky.SelectionSet(e.selectionSet)},Directive(e){var t=`@`+e.name.value;return e.arguments&&e.arguments.length&&(t+=`(`+Hy(e.arguments,`, `,Ky.Argument)+`)`),t},NamedType:e=>e.name.value,ListType:e=>`[`+qy(e.type)+`]`,NonNullType:e=>qy(e.type)+`!`},qy=e=>Ky[e.kind](e);function Jy(e){return Gy=`
943
+ `,Ky[e.kind]?Ky[e.kind](e):``}var Yy=()=>{},Xy=Yy;function Zy(e){return{tag:0,0:e}}function Qy(e){return{tag:1,0:e}}var $y=()=>typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`,eb=e=>e;function tb(e){return t=>n=>{var r=Xy;t((t=>{t===0?n(0):t.tag===0?(r=t[0],n(t)):e(t[0])?n(t):r(0)}))}}function nb(e){return t=>n=>t((t=>{t===0||t.tag===0?n(t):n(Qy(e(t[0])))}))}function rb(e){return t=>n=>{var r=[],i=Xy,a=!1,o=!1;t((t=>{o||(t===0?(o=!0,r.length||n(0)):t.tag===0?i=t[0]:(a=!1,(function(e){var t=Xy;e((e=>{if(e===0){if(r.length){var s=r.indexOf(t);s>-1&&(r=r.slice()).splice(s,1),r.length||(o?n(0):a||(a=!0,i(0)))}}else e.tag===0?(r.push(t=e[0]),t(0)):r.length&&(n(e),t(0))}))})(e(t[0])),a||(a=!0,i(0))))})),n(Zy((e=>{if(e===1){o||(o=!0,i(1));for(var t=0,n=r,s=r.length;t<s;t++)n[t](1);r.length=0}else{!o&&!a?(a=!0,i(0)):a=!1;for(var c=0,l=r,u=r.length;c<u;c++)l[c](0)}})))}}function ib(e){return rb(eb)(e)}function ab(e){return ib(_b(e))}function ob(e){return t=>n=>{var r=!1;t((t=>{if(!r)if(t===0)r=!0,n(0),e();else if(t.tag===0){var i=t[0];n(Zy((t=>{t===1?(r=!0,i(1),e()):i(t)})))}else n(t)}))}}function sb(e){return t=>n=>{var r=!1;t((t=>{if(!r)if(t===0)r=!0,n(0);else if(t.tag===0){var i=t[0];n(Zy((e=>{e===1&&(r=!0),i(e)})))}else e(t[0]),n(t)}))}}function cb(e){return t=>n=>t((t=>{t===0?n(0):t.tag===0?(n(t),e()):n(t)}))}function lb(e){var t=[],n=Xy,r=!1;return i=>{t.push(i),t.length===1&&e((e=>{if(e===0){for(var i=0,a=t,o=t.length;i<o;i++)a[i](0);t.length=0}else if(e.tag===0)n=e[0];else{r=!1;for(var s=0,c=t,l=t.length;s<l;s++)c[s](e)}})),i(Zy((e=>{if(e===1){var a=t.indexOf(i);a>-1&&(t=t.slice()).splice(a,1),t.length||n(1)}else r||(r=!0,n(0))})))}}function ub(e){return t=>n=>{var r=Xy,i=Xy,a=!1,o=!1,s=!1,c=!1;t((t=>{c||(t===0?(c=!0,s||n(0)):t.tag===0?r=t[0]:(s&&(i(1),i=Xy),a?a=!1:(a=!0,r(0)),(function(e){s=!0,e((e=>{s&&(e===0?(s=!1,c?n(0):a||(a=!0,r(0))):e.tag===0?(o=!1,(i=e[0])(0)):(n(e),o?o=!1:i(0)))}))})(e(t[0]))))})),n(Zy((e=>{e===1?(c||(c=!0,r(1)),s&&(s=!1,i(1))):(!c&&!a&&(a=!0,r(0)),s&&!o&&(o=!0,i(0)))})))}}function db(e){return t=>n=>{var r=Xy,i=!1,a=0;t((t=>{i||(t===0?(i=!0,n(0)):t.tag===0?e<=0?(i=!0,n(0),t[0](1)):r=t[0]:a++<e?(n(t),!i&&a>=e&&(i=!0,n(0),r(1))):n(t))})),n(Zy((t=>{t===1&&!i?(i=!0,r(1)):t===0&&!i&&a<e&&r(0)})))}}function fb(e){return t=>n=>{var r=Xy,i=Xy,a=!1;t((t=>{a||(t===0?(a=!0,i(1),n(0)):t.tag===0?(r=t[0],e((e=>{e===0||(e.tag===0?(i=e[0])(0):(a=!0,i(1),r(1),n(0)))}))):n(t))})),n(Zy((e=>{e===1&&!a?(a=!0,r(1),i(1)):a||r(0)})))}}function pb(e,t){return n=>r=>{var i=Xy,a=!1;n((n=>{a||(n===0?(a=!0,r(0)):n.tag===0?(i=n[0],r(n)):e(n[0])?r(n):(a=!0,t&&r(n),r(0),i(1)))}))}}function mb(e){return t=>e()(t)}function hb(e){return t=>{var n=e[$y()]&&e[$y()]()||e,r=!1,i=!1,a=!1,o;t(Zy((async e=>{if(e===1)r=!0,n.return&&n.return();else if(i)a=!0;else{for(a=i=!0;a&&!r;)if((o=await n.next()).done)r=!0,n.return&&await n.return(),t(0);else try{a=!1,t(Qy(o.value))}catch(e){if(n.throw)(r=!!(await n.throw(e)).done)&&t(0);else throw e}i=!1}})))}}function gb(e){return e[Symbol.asyncIterator]?hb(e):t=>{var n=e[Symbol.iterator](),r=!1,i=!1,a=!1,o;t(Zy((e=>{if(e===1)r=!0,n.return&&n.return();else if(i)a=!0;else{for(a=i=!0;a&&!r;)if((o=n.next()).done)r=!0,n.return&&n.return(),t(0);else try{a=!1,t(Qy(o.value))}catch(e){if(n.throw)(r=!!n.throw(e).done)&&t(0);else throw e}i=!1}})))}}var _b=gb;function vb(e){return t=>{var n=!1;t(Zy((r=>{r===1?n=!0:n||(n=!0,t(Qy(e)),t(0))})))}}function yb(e){return t=>{var n=!1,r=e({next(e){n||t(Qy(e))},complete(){n||(n=!0,t(0))}});t(Zy((e=>{e===1&&!n&&(n=!0,r())})))}}function bb(){var e,t;return{source:lb(yb((n=>(e=n.next,t=n.complete,Yy)))),next(t){e&&e(t)},complete(){t&&t()}}}function xb(e){return t=>{var n=Xy,r=!1;return t((t=>{t===0?r=!0:t.tag===0?(n=t[0])(0):r||(e(t[0]),n(0))})),{unsubscribe(){r||(r=!0,n(1))}}}}function Sb(e){xb((e=>{}))(e)}function Cb(e){return new Promise((t=>{var n=Xy,r;e((e=>{e===0?Promise.resolve(r).then(t):e.tag===0?(n=e[0])(0):(r=e[0],n(0))}))}))}var wb=(...e)=>{for(var t=e[0],n=1,r=e.length;n<r;n++)t=e[n](t);return t},Tb=e=>e&&typeof e.message==`string`&&(e.extensions||e.name===`GraphQLError`)?e:typeof e==`object`&&typeof e.message==`string`?new Sy(e.message,e.nodes,e.source,e.positions,e.path,e,e.extensions||{}):new Sy(e),Eb=class extends Error{constructor(e){var t=(e.graphQLErrors||[]).map(Tb),n=((e,t)=>{var n=``;if(e)return`[Network] ${e.message}`;if(t)for(var r=0,i=t.length;r<i;r++)n&&(n+=`
944
+ `),n+=`[GraphQL] ${t[r].message}`;return n})(e.networkError,t);super(n),this.name=`CombinedError`,this.message=n,this.graphQLErrors=t,this.networkError=e.networkError,this.response=e.response}toString(){return this.message}},Db=(e,t)=>{for(var n=0|(t||5381),r=0,i=0|e.length;r<i;r++)n=(n<<5)+n+e.charCodeAt(r);return n},Ob=new Set,kb=new WeakMap,Ab=(e,t)=>{if(e===null||Ob.has(e))return`null`;if(typeof e!=`object`)return JSON.stringify(e)||``;if(e.toJSON)return Ab(e.toJSON(),t);if(Array.isArray(e)){for(var n=`[`,r=0,i=e.length;r<i;r++)n.length>1&&(n+=`,`),n+=Ab(e[r],t)||`null`;return n+=`]`}else if(!t&&(Pb!==Nb&&e instanceof Pb||Fb!==Nb&&e instanceof Fb))return`null`;var a=Object.keys(e).sort();if(!a.length&&e.constructor&&Object.getPrototypeOf(e).constructor!==Object.prototype.constructor){var o=kb.get(e)||Math.random().toString(36).slice(2);return kb.set(e,o),Ab({__key:o},t)}Ob.add(e);for(var s=`{`,c=0,l=a.length;c<l;c++){var u=Ab(e[a[c]],t);u&&(s.length>1&&(s+=`,`),s+=Ab(a[c],t)+`:`+u)}return Ob.delete(e),s+=`}`},jb=(e,t,n)=>{if(!(typeof n!=`object`||!n||n.toJSON||Ob.has(n)))if(Array.isArray(n))for(var r=0,i=n.length;r<i;r++)jb(e,`${t}.${r}`,n[r]);else if(n instanceof Pb||n instanceof Fb)e.set(t,n);else for(var a in Ob.add(n),n)jb(e,`${t}.${a}`,n[a])},Mb=(e,t)=>(Ob.clear(),Ab(e,t||!1)),Nb=class{},Pb=typeof File<`u`?File:Nb,Fb=typeof Blob<`u`?Blob:Nb,Ib=/("{3}[\s\S]*"{3}|"(?:\\.|[^"])*")/g,Lb=/(?:#[^\n\r]+)?(?:[\r\n]+|$)/g,Rb=(e,t)=>t%2==0?e.replace(Lb,`
945
+ `):e,zb=e=>e.split(Ib).map(Rb).join(``).trim(),Bb=new Map,Vb=new Map,Hb=e=>{var t;return typeof e==`string`?t=zb(e):e.loc&&Vb.get(e.__key)===e?t=e.loc.source.body:(t=Bb.get(e)||zb(Jy(e)),Bb.set(e,t)),typeof e!=`string`&&!e.loc&&(e.loc={start:0,end:t.length,source:{body:t,name:`gql`,locationOffset:{line:1,column:1}}}),t},Ub=e=>{var t;if(e.documentId)t=Db(e.documentId);else if(t=Db(Hb(e)),e.definitions){var n=Kb(e);n&&(t=Db(`\n# ${n}`,t))}return t},Wb=e=>{var t,n;return typeof e==`string`?(t=Ub(e),n=Vb.get(t)||Vy(e,{noLocation:!0})):(t=e.__key||Ub(e),n=Vb.get(t)||e),n.loc||Hb(n),n.__key=t,Vb.set(t,n),n},Gb=(e,t,n)=>{var r=t||{},i=Wb(e),a=Mb(r,!0),o=i.__key;return a!==`{}`&&(o=Db(a,o)),{key:o,query:i,variables:r,extensions:n}},Kb=e=>{for(var t=0,n=e.definitions.length;t<n;t++){var r=e.definitions[t];if(r.kind===xy.OPERATION_DEFINITION)return r.name?r.name.value:void 0}},qb=(e,t,n)=>{if(!(`data`in t||`errors`in t&&Array.isArray(t.errors)))throw Error(`No Content`);var r=e.kind===`subscription`;return{operation:e,data:t.data,error:Array.isArray(t.errors)?new Eb({graphQLErrors:t.errors,response:n}):void 0,extensions:t.extensions?{...t.extensions}:void 0,hasNext:t.hasNext==null?r:t.hasNext,stale:!1}},Jb=(e,t)=>{if(typeof e==`object`&&e){if(Array.isArray(e)){e=[...e];for(var n=0,r=t.length;n<r;n++)e[n]=Jb(e[n],t[n]);return e}if(!e.constructor||e.constructor===Object){for(var i in e={...e},t)e[i]=Jb(e[i],t[i]);return e}}return t},Yb=(e,t,n,r)=>{var i=e.error?e.error.graphQLErrors:[],a=!!e.extensions||!!(t.payload||t).extensions,o={...e.extensions,...(t.payload||t).extensions},s=t.incremental;`path`in t&&(s=[t]);var c={data:e.data};if(s)for(var l=function(){var e=s[u];Array.isArray(e.errors)&&i.push(...e.errors),e.extensions&&(Object.assign(o,e.extensions),a=!0);var t=`data`,n=c,l=[];if(e.path)l=e.path;else if(r){var d=r.find((t=>t.id===e.id));l=e.subPath?[...d.path,...e.subPath]:d.path}for(var f=0,p=l.length;f<p;t=l[f++])n=n[t]=Array.isArray(n[t])?[...n[t]]:{...n[t]};if(e.items)for(var m=+t>=0?t:0,h=0,g=e.items.length;h<g;h++)n[m+h]=Jb(n[m+h],e.items[h]);else e.data!==void 0&&(n[t]=Jb(n[t],e.data))},u=0,d=s.length;u<d;u++)l();else c.data=(t.payload||t).data||e.data,i=t.errors||t.payload&&t.payload.errors||i;return{operation:e.operation,data:c.data,error:i.length?new Eb({graphQLErrors:i,response:n}):void 0,extensions:a?o:void 0,hasNext:t.hasNext==null?e.hasNext:t.hasNext,stale:!1}},Xb=(e,t,n)=>({operation:e,data:void 0,error:new Eb({networkError:t,response:n}),extensions:void 0,hasNext:!1,stale:!1});function Zb(e){var t={query:void 0,documentId:void 0,operationName:Kb(e.query),variables:e.variables||void 0,extensions:e.extensions};return`documentId`in e.query&&e.query.documentId&&(!e.query.definitions||!e.query.definitions.length)?t.documentId=e.query.documentId:(!e.extensions||!e.extensions.persistedQuery||e.extensions.persistedQuery.miss)&&(t.query=Hb(e.query)),t}var Qb=(e,t)=>{var n=e.kind===`query`&&e.context.preferGetMethod;if(!n||!t)return e.context.url;var r=$b(e.context.url);for(var i in t){var a=t[i];a&&r[1].set(i,typeof a==`object`?Mb(a):a)}var o=r.join(`?`);return o.length>2047&&n!==`force`?(e.context.preferGetMethod=!1,e.context.url):o},$b=e=>{var t=e.indexOf(`?`);return t>-1?[e.slice(0,t),new URLSearchParams(e.slice(t+1))]:[e,new URLSearchParams]},ex=(e,t)=>{if(t&&!(e.kind===`query`&&e.context.preferGetMethod)){var n=Mb(t),r=(e=>{var t=new Map;return(Pb!==Nb||Fb!==Nb)&&(Ob.clear(),jb(t,`variables`,e)),t})(t.variables);if(r.size){var i=new FormData;i.append(`operations`,n),i.append(`map`,Mb({...[...r.keys()].map((e=>[e]))}));var a=0;for(var o of r.values())i.append(``+a++,o);return i}return n}},tx=(e,t)=>{var n={accept:e.kind===`subscription`?`text/event-stream, multipart/mixed`:`application/graphql-response+json, application/graphql+json, application/json, text/event-stream, multipart/mixed`},r=(typeof e.context.fetchOptions==`function`?e.context.fetchOptions():e.context.fetchOptions)||{};if(r.headers)if((e=>`has`in e&&!Object.keys(e).length)(r.headers))r.headers.forEach(((e,t)=>{n[t]=e}));else if(Array.isArray(r.headers))r.headers.forEach(((e,t)=>{Array.isArray(e)?n[e[0]]?n[e[0]]=`${n[e[0]]},${e[1]}`:n[e[0]]=e[1]:n[t]=e}));else for(var i in r.headers)n[i.toLowerCase()]=r.headers[i];var a=ex(e,t);return typeof a==`string`&&!n[`content-type`]&&(n[`content-type`]=`application/json`),{...r,method:a?`POST`:`GET`,body:a,headers:n}},nx=/boundary="?([^=";]+)"?/i,rx=/data: ?([^\n]+)/;async function*ix(e){if(e.body[Symbol.asyncIterator])for await(var t of e.body)yield t;else{var n=e.body.getReader(),r;try{for(;!(r=await n.read()).done;)yield r.value}finally{n.cancel()}}}async function*ax(e,t){var n=typeof TextDecoder<`u`?new TextDecoder:null,r=``,i;for await(var a of e)for(r+=a.constructor.name===`Buffer`?a.toString():n.decode(a,{stream:!0});(i=r.indexOf(t))>-1;)yield r.slice(0,i),r=r.slice(i+t.length)}async function*ox(e,t,n){var r=!0,i=null,a;try{yield await Promise.resolve();var o=(a=await(e.context.fetch||fetch)(t,n)).headers.get(`Content-Type`)||``,s=/multipart\/mixed/i.test(o)?async function*(e,t){var n=e.match(nx),r=`--`+(n?n[1]:`-`),i=!0,a;for await(var o of ax(ix(t),`\r
946
+ `+r)){if(i){i=!1;var s=o.indexOf(r);if(s>-1)o=o.slice(s+r.length);else continue}try{yield a=JSON.parse(o.slice(o.indexOf(`\r
947
+ \r
948
+ `)+4))}catch(e){if(!a)throw e}if(a&&!1===a.hasNext)break}a&&!1!==a.hasNext&&(yield{hasNext:!1})}(o,a):/text\/event-stream/i.test(o)?async function*(e){var t;for await(var n of ax(ix(e),`
949
+
950
+ `)){var r=n.match(rx);if(r){var i=r[1];try{yield t=JSON.parse(i)}catch(e){if(!t)throw e}if(t&&!1===t.hasNext)break}}t&&!1!==t.hasNext&&(yield{hasNext:!1})}(a):/text\//i.test(o)?async function*(e){var t=await e.text();try{yield JSON.parse(t)}catch{throw Error(t)}}(a):async function*(e){yield JSON.parse(await e.text())}(a),c;for await(var l of s)l.pending&&!i?c=l.pending:l.pending&&(c=[...c,...l.pending]),i=i?Yb(i,l,a,c):qb(e,l,a),r=!1,yield i,r=!0;i||(yield i=qb(e,{},a))}catch(t){if(!r)throw t;yield Xb(e,a&&(a.status<200||a.status>=300)&&a.statusText?Error(a.statusText):t,a)}}function sx(e,t,n){var r;return typeof AbortController<`u`&&(n.signal=(r=new AbortController).signal),ob((()=>{r&&r.abort()}))(tb((e=>!!e))(hb(ox(e,t,n))))}function cx(e){var t=t=>e(t);return t.toPromise=()=>Cb(db(1)(tb((e=>!e.stale&&!e.hasNext))(t))),t.then=(e,n)=>t.toPromise().then(e,n),t.subscribe=e=>xb(e)(t),t}function lx(e,t,n){return{...t,kind:e,context:t.context?{...t.context,...n}:n||t.context}}var ux=()=>{},dx=({forward:e,dispatchDebug:t})=>t=>ab([rb((e=>{var n=Zb(e),r=Qb(e,n),i=tx(e,n);return fb(tb((t=>t.kind===`teardown`&&t.key===e.key))(t))(sx(e,r,i))}))(tb((e=>e.kind!==`teardown`&&(e.kind!==`subscription`||!!e.context.fetchSubscriptions)))(t)),e(tb((e=>e.kind===`teardown`||e.kind===`subscription`&&!e.context.fetchSubscriptions))(t))]),fx=e=>({client:t,forward:n,dispatchDebug:r})=>e.reduceRight(((e,n)=>n({client:t,forward(t){return lb(e(lb(t)))},dispatchDebug(e){}})),n),px=({dispatchDebug:e})=>e=>tb((e=>!1))(e),mx=function e(t){var n=0,r=new Map,i=new Map,a=new Set,o=[],s={url:t.url,fetchSubscriptions:t.fetchSubscriptions,fetchOptions:t.fetchOptions,fetch:t.fetch,preferGetMethod:t.preferGetMethod,requestPolicy:t.requestPolicy||`cache-first`},c=bb();function l(e){(e.kind===`mutation`||e.kind===`teardown`||!a.has(e.key))&&(e.kind===`teardown`?a.delete(e.key):e.kind!==`mutation`&&a.add(e.key),c.next(e))}var u=!1;function d(e){if(e&&l(e),!u){for(u=!0;u&&(e=o.shift());)l(e);u=!1}}var f=e=>{var t=fb(tb((t=>t.kind===`teardown`&&t.key===e.key))(c.source))(tb((t=>t.operation.kind===e.kind&&t.operation.key===e.key&&(!t.operation.context._instance||t.operation.context._instance===e.context._instance)))(g));return t=e.kind===`query`?ub((t=>{var n=vb(t);return t.stale||t.hasNext?n:ab([n,nb((()=>(t.stale=!0,t)))(db(1)(tb((t=>t.key===e.key))(c.source)))])}))(t):pb((e=>!!e.hasNext),!0)(t),t=e.kind===`mutation`?cb((()=>{l(e)}))(t):ob((()=>{a.delete(e.key),r.delete(e.key),i.delete(e.key),u=!1;for(var t=o.length-1;t>=0;t--)o[t].key===e.key&&o.splice(t,1);l(lx(`teardown`,e,e.context))}))(sb((t=>{if(t.stale)if(!t.hasNext)a.delete(e.key);else for(var n=0;n<o.length;n++){var i=o[n];if(i.key===t.operation.key){a.delete(i.key);break}}else t.hasNext||a.delete(e.key);r.set(e.key,t)}))(t)),lb(t)},p=this instanceof e?this:Object.create(e.prototype),m=Object.assign(p,{suspense:!!t.suspense,operations$:c.source,reexecuteOperation(e){if(e.kind===`teardown`)d(e);else if(e.kind===`mutation`)o.push(e),Promise.resolve().then(d);else if(i.has(e.key)){for(var t=!1,n=0;n<o.length;n++)o[n].key===e.key&&(o[n]=e,t=!0);t||a.has(e.key)&&e.context.requestPolicy!==`network-only`?(a.delete(e.key),Promise.resolve().then(d)):(o.push(e),Promise.resolve().then(d))}},createRequestOperation(e,t,r){return r||={},lx(e,t,{_instance:e===`mutation`?n=n+1|0:void 0,...s,...r,requestPolicy:r.requestPolicy||s.requestPolicy,suspense:r.suspense||!1!==r.suspense&&m.suspense})},executeRequestOperation(e){return e.kind===`mutation`?cx(f(e)):cx(mb((()=>{var t=i.get(e.key);t||i.set(e.key,t=f(e)),t=cb((()=>{d(e)}))(t);var n=r.get(e.key);return e.kind===`query`&&n&&(n.stale||n.hasNext)?ub(vb)(ab([t,tb((t=>t===r.get(e.key)))(vb(n))])):t})))},executeQuery(e,t){var n=m.createRequestOperation(`query`,e,t);return m.executeRequestOperation(n)},executeSubscription(e,t){var n=m.createRequestOperation(`subscription`,e,t);return m.executeRequestOperation(n)},executeMutation(e,t){var n=m.createRequestOperation(`mutation`,e,t);return m.executeRequestOperation(n)},readQuery(e,t,n){var r=null;return xb((e=>{r=e}))(m.query(e,t,n)).unsubscribe(),r},query:(e,t,n)=>m.executeQuery(Gb(e,t),n),subscription:(e,t,n)=>m.executeSubscription(Gb(e,t),n),mutation:(e,t,n)=>m.executeMutation(Gb(e,t),n)}),h=ux,g=lb(fx(t.exchanges)({client:m,dispatchDebug:h,forward:px({dispatchDebug:h})})(c.source));return Sb(g),m},hx=u(s(((e,t)=>{var n=function(){function e(e,t){if(typeof e!=`function`)throw TypeError(`DataLoader must be constructed with a function which accepts `+(`Array<key> and returns Promise<Array<value>>, but got: `+e+`.`));this._batchLoadFn=e,this._maxBatchSize=l(t),this._batchScheduleFn=u(t),this._cacheKeyFn=d(t),this._cacheMap=f(t),this._batch=null,this.name=p(t)}var t=e.prototype;return t.load=function(e){if(e==null)throw TypeError(`The loader.load() function must be called with a value, `+(`but got: `+String(e)+`.`));var t=a(this),n=this._cacheMap,r;if(n){r=this._cacheKeyFn(e);var i=n.get(r);if(i){var o=t.cacheHits||=[];return new Promise(function(e){o.push(function(){e(i)})})}}t.keys.push(e);var s=new Promise(function(e,n){t.callbacks.push({resolve:e,reject:n})});return n&&n.set(r,s),s},t.loadMany=function(e){if(!m(e))throw TypeError(`The loader.loadMany() function must be called with Array<key> `+(`but got: `+e+`.`));for(var t=[],n=0;n<e.length;n++)t.push(this.load(e[n]).catch(function(e){return e}));return Promise.all(t)},t.clear=function(e){var t=this._cacheMap;if(t){var n=this._cacheKeyFn(e);t.delete(n)}return this},t.clearAll=function(){var e=this._cacheMap;return e&&e.clear(),this},t.prime=function(e,t){var n=this._cacheMap;if(n){var r=this._cacheKeyFn(e);if(n.get(r)===void 0){var i;t instanceof Error?(i=Promise.reject(t),i.catch(function(){})):i=Promise.resolve(t),n.set(r,i)}}return this},e}(),r=typeof process==`object`&&typeof process.nextTick==`function`?function(e){i||=Promise.resolve(),i.then(function(){process.nextTick(e)})}:typeof setImmediate==`function`?function(e){setImmediate(e)}:function(e){setTimeout(e)},i;function a(e){var t=e._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;var n={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=n,e._batchScheduleFn(function(){o(e,n)}),n}function o(e,t){if(t.hasDispatched=!0,t.keys.length===0){c(t);return}var n;try{n=e._batchLoadFn(t.keys)}catch(n){return s(e,t,TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function `+(`errored synchronously: `+String(n)+`.`)))}if(!n||typeof n.then!=`function`)return s(e,t,TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did `+(`not return a Promise: `+String(n)+`.`)));n.then(function(e){if(!m(e))throw TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did `+(`not return a Promise of an Array: `+String(e)+`.`));if(e.length!==t.keys.length)throw TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.`+(`
951
+
952
+ Keys:
953
+ `+String(t.keys))+(`
954
+
955
+ Values:
956
+ `+String(e)));c(t);for(var n=0;n<t.callbacks.length;n++){var r=e[n];r instanceof Error?t.callbacks[n].reject(r):t.callbacks[n].resolve(r)}}).catch(function(n){s(e,t,n)})}function s(e,t,n){c(t);for(var r=0;r<t.keys.length;r++)e.clear(t.keys[r]),t.callbacks[r].reject(n)}function c(e){if(e.cacheHits)for(var t=0;t<e.cacheHits.length;t++)e.cacheHits[t]()}function l(e){if(!(!e||e.batch!==!1))return 1;var t=e&&e.maxBatchSize;if(t===void 0)return 1/0;if(typeof t!=`number`||t<1)throw TypeError(`maxBatchSize must be a positive number: `+t);return t}function u(e){var t=e&&e.batchScheduleFn;if(t===void 0)return r;if(typeof t!=`function`)throw TypeError(`batchScheduleFn must be a function: `+t);return t}function d(e){var t=e&&e.cacheKeyFn;if(t===void 0)return function(e){return e};if(typeof t!=`function`)throw TypeError(`cacheKeyFn must be a function: `+t);return t}function f(e){if(!(!e||e.cache!==!1))return null;var t=e&&e.cacheMap;if(t===void 0)return new Map;if(t!==null){var n=[`get`,`set`,`delete`,`clear`].filter(function(e){return t&&typeof t[e]!=`function`});if(n.length!==0)throw TypeError(`Custom cacheMap missing methods: `+n.join(`, `))}return t}function p(e){return e&&e.name?e.name:null}function m(e){return typeof e==`object`&&!!e&&typeof e.length==`number`&&(e.length===0||e.length>0&&Object.prototype.hasOwnProperty.call(e,e.length-1))}t.exports=n}))(),1),gx=1e4,_x=16,vx=e=>{let t;try{t=e.contentWindow}catch{return!0}if(!t)return!0;try{let e=t.location.href;return e!==``&&e!==`about:blank`}catch{return!0}},yx=(e,t=gx)=>new Promise(n=>{if(vx(e))return n();let r=()=>{clearInterval(i),clearTimeout(a),e.removeEventListener(`load`,r),n()},i=setInterval(()=>{vx(e)&&r()},_x),a=setTimeout(r,t);e.addEventListener(`load`,r)}),bx=32,xx=8,Sx=120,Cx=typeof CSS<`u`&&CSS.supports(`clip-path`,`path('M0 0H1V1H0Z')`),wx=typeof CSS<`u`&&CSS.supports(`clip-path`,`polygon(nonzero, 0px 0px, 1px 0px, 1px 1px)`),Tx=e=>{let t=e.style;t.setProperty(`display`,`block`,`important`),t.setProperty(`position`,`fixed`,`important`),t.setProperty(`top`,`0`,`important`),t.setProperty(`left`,`0`,`important`),t.setProperty(`width`,`100%`,`important`),t.setProperty(`height`,`100%`,`important`),t.setProperty(`border`,`none`,`important`),t.setProperty(`padding`,`0`,`important`),t.setProperty(`box-sizing`,`border-box`,`important`),t.setProperty(`clip-path`,`inset(100%)`,`important`),t.setProperty(`background`,`transparent`),t.setProperty(`color-scheme`,`normal`),t.setProperty(`z-index`,`2147483647`),e.setAttribute(`title`,`FKN`)},Ex=({x:e,y:t,width:n,height:r,radius:i})=>{if(!i)return`M${e} ${t}h${n}v${r}h${-n}Z`;let a=Math.min(n,r)/2,[o,s,c,l]=i.map(e=>Math.max(0,Math.min(e,a)));return`M${e+o} ${t}h${n-o-s}a${s} ${s} 0 0 1 ${s} ${s}v${r-s-c}a${c} ${c} 0 0 1 ${-c} ${c}h${-(n-c-l)}a${l} ${l} 0 0 1 ${-l} ${-l}v${-(r-l-o)}a${o} ${o} 0 0 1 ${o} ${-o}Z`},Dx=()=>Cx&&wx,Ox=({x:e,y:t,width:n,height:r})=>[[e,t],[e+n,t],[e+n,t+r],[e,t+r],[e,t]],kx=e=>{let t=e[0];if(!t)return[];let n=Ox(t)[0],r=[];return e.forEach((t,i)=>{r.push(...Ox(t)),i>0&&i<e.length-1&&r.push(n)}),r},Ax=e=>`polygon(nonzero, ${kx(e).map(([e,t])=>`${e}px ${t}px`).join(`, `)})`,jx=({x:e,y:t,width:n,height:r,radius:i},a)=>{let o=`${t}px ${a.width-e-n}px ${a.height-t-r}px ${e}px`;return i?`inset(${o} round ${i.map(e=>`${e}px`).join(` `)})`:`inset(${o})`},Mx=(e,t,n)=>{if(t)return`none`;if(e.length===0)return`inset(100%)`;let r=e.length===1?e[0]:void 0;return r?jx(r,n):wx&&e.length<=5&&!e.some(e=>e.radius)?Ax(e):`path('${e.map(Ex).join(``)}')`},Nx=e=>{if(e.length<2)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-n}},Px=(e,t,n)=>t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height,Fx=16,Ix=(e,t,n)=>t===1?e*Fx:t===2?e*n:e,Lx=(e,t,n)=>{let r=getComputedStyle(e);return n!==0&&/auto|scroll/.test(r.overflowY)&&e.scrollHeight>e.clientHeight?!0:t!==0&&/auto|scroll/.test(r.overflowX)&&e.scrollWidth>e.clientWidth},Rx=(e,t,n)=>{for(let r=e;r;r=r.parentElement)if(Lx(r,t,n))return r;return document.scrollingElement},zx=null,Bx=null,Vx=e=>({width:e.offsetWidth||window.innerWidth,height:e.offsetHeight||window.innerHeight}),Hx=e=>{if(!Bx||!zx||!Px(Bx,e.clientX,e.clientY))return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t||t===zx)return;let n=Ix(e.deltaX,e.deltaMode,window.innerWidth),r=Ix(e.deltaY,e.deltaMode,window.innerHeight),i=Rx(t,n,r);i&&(i.scrollBy({left:n,top:r,behavior:`instant`}),e.cancelable&&e.preventDefault())},Ux=e=>{let t=Bx!==null;Bx=e,t!==(e!==null)&&(e?window.addEventListener(`wheel`,Hx,{capture:!0,passive:!1}):window.removeEventListener(`wheel`,Hx,{capture:!0}))},Wx=0,Gx=e=>{if(e===Wx)return;Wx=e;let t=document.documentElement.style;e>0?(t.setProperty(`margin-top`,`${e}px`,`important`),t.setProperty(`--fkn-inset-top`,`${e}px`)):(t.removeProperty(`margin-top`),t.removeProperty(`--fkn-inset-top`))},Kx=(e,{modal:t,rects:n,inset:r},i)=>{if(Gx(r),!Cx){let r=t||n.length>0;e.style.setProperty(`pointer-events`,r?`auto`:`none`,`important`),e.style.setProperty(`visibility`,r?`visible`:`hidden`,`important`);return}let a=Mx(n,t,i),o=a===`none`||CSS.supports(`clip-path`,a)?a:`inset(100%)`;e.style.setProperty(`clip-path`,o,`important`),Ux(t||o!==a?null:Nx(n))},qx=e=>{if(typeof e!=`object`||!e)return 0;let{top:t}=e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?0:Math.min(Math.round(t),Sx)},Jx=e=>{if(!(!Array.isArray(e)||e.length!==4)&&e.every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0))return e.some(e=>e>0)?e:void 0},Yx=(e,t)=>{if(typeof e!=`object`||!e)return null;let{x:n,y:r,width:i,height:a}=e;if(![n,r,i,a].every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let o=t.width,s=t.height,c=Math.max(0,Math.min(Math.round(n),o)),l=Math.max(0,Math.min(Math.round(r),s)),u=Math.max(c,Math.min(Math.round(n+i),o)),d=Math.max(l,Math.min(Math.round(r+a),s)),f=Jx(e.radius);return{x:c,y:l,width:u-c,height:d-l,...f?{radius:f}:{}}},Xx={"not-rendered":`this page is not painting it at all, so it or an ancestor is display:none, or the frame was moved out of the layout`,clipped:`it is clipped away or positioned outside the viewport`,"not-shown":`it is rendered but would not be seen, so either something is drawn over it, or it or an ancestor has opacity below 1, visibility:hidden, or a filter`},Zx=e=>Array.isArray(e)?e.slice(0,xx).flatMap(e=>{if(typeof e!=`object`||!e)return[];let{kind:t,cause:n,level:r}=e;return typeof t!=`string`||t.length>40||typeof n!=`string`||!(n in Xx)||r!==`full`&&r!==`liveness`?[]:[{kind:t,cause:n,level:r}]}):[],Qx=new Set,$x=e=>{for(let{kind:t,cause:n,level:r}of e)Qx.has(t)||(Qx.add(t),console.error(`[FKN] The FKN ${JSON.stringify(t)} is not visible on this page: ${Xx[n]}. Nobody using this page can see or answer it.
957
+ @fkn/lib draws its UI inside <iframe title="FKN"> and sets display, position, top, left, width, height, border, padding, box-sizing, clip-path and z-index on that element. Leave those as they are, then check for an ancestor with opacity, visibility, display or a clipping transform, and for an element stacked above it.`+(r===`liveness`?`
958
+ This browser reports limited detail, so the cause above is a best guess.`:``)))},eS=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=e,r=(Array.isArray(n.rects)?n.rects.slice(0,bx):[]).map(e=>Yx(e,t)).filter(e=>e!==null&&e.width>0&&e.height>0);return{modal:n.modal===!0,rects:r,hidden:Zx(n.hidden),inset:qx(n.inset)}},tS=()=>zx!==null,nS=null,rS=null,iS=()=>{if(!zx||nS===null)return;let e=Vx(zx),t=eS(nS,e);t&&Kx(zx,t,e)},aS=e=>{typeof ResizeObserver>`u`||(rS??=new ResizeObserver(iS),rS.disconnect(),rS.observe(e))},oS=e=>{Tx(e),Kx(e,{modal:!1,rects:[],hidden:[],inset:0},Vx(e)),zx=e,aS(e)},sS=e=>{if(!zx)return;let t=Vx(zx),n=eS(e,t);n&&(nS=e,Kx(zx,n,t),$x(n.hidden))},cS=`https://fkn.app`,lS=typeof globalThis<`u`&&globalThis.document?globalThis.document:void 0,uS=typeof globalThis<`u`&&globalThis.crossOriginIsolated===!0,dS=`${cS}/api${uS?`?coi=1`:``}`,fS=`fkn-api-port`,pS=`fkn-api-port-ack`,mS=2e3,hS=()=>{if(!lS||typeof window>`u`||window.parent===window)return Promise.resolve(void 0);let e;try{e=window.parent}catch{return Promise.resolve(void 0)}let t=new MessageChannel;return new Promise(n=>{let r=e=>{if(clearTimeout(a),t.port1.removeEventListener(`message`,i),!e)try{t.port1.close()}catch{}n(e)},i=e=>{e.data?.type===pS&&r(t.port1)},a=setTimeout(()=>r(void 0),mS);t.port1.addEventListener(`message`,i),t.port1.start();try{e.postMessage({type:fS},cS,[t.port2])}catch{r(void 0)}})},gS,_S=()=>{if(gS||!lS)return gS;let e=lS.querySelector(`iframe[src="${dS}"]`);if(e)gS=e;else{let e=lS.createElement(`iframe`);uS&&e.setAttribute(`allow`,`cross-origin-isolated`),e.src=dS,lS.body.appendChild(e),gS=e}return oS(gS),gS},vS=(async()=>{if(!lS)return;let e=await hS();if(e)return{receive:e,emit:e};let t=_S();if(!t)return;await yx(t);let n=t.contentWindow;return n?{receive:window,emit:n}:void 0})(),yS=e=>{let t,n=()=>{},r=new Promise(e=>{n=e}),i=new Set,a=new Set,o=0,s=0;(async()=>{for await(let r of e){let e=(t?.epoch??0)+1;t={remote:r,epoch:e},e===1&&n(r);let o=[...a];a.clear();let s=Error(`FKN: the broker was replaced while this call was pending; retry it`);for(let e of o)try{e(s)}catch{}for(let t of[...i])try{t(r,e)}catch{}}})().catch(()=>{});let c=async(e,n)=>{let i=t?.remote??await r;for(let t of e.slice(0,-1))i=i[t];let c=i[e[e.length-1]??``];o=Date.now(),s+=1;let l=()=>{},u=new Promise((e,t)=>{l=t});a.add(l);try{return await Promise.race([Promise.resolve(c.apply(i,n)),u])}finally{--s,a.delete(l),o=Date.now()}},l=new Map,u=e=>{let n=e.join(`\0`),r=l.get(n);if(r)return r;let i=new Proxy(function(){},{get:(n,r)=>{if(typeof r!=`string`||r===`then`)return;let i=t;if(i){let t=i.remote;for(let n of e)t=t?.[n];if(t?.[r]===void 0)return}return u([...e,r])},apply:(t,n,r)=>c(e,r)});return l.set(n,i),i};return{facade:u([]),first:r.then(()=>{}),current:()=>t,onEpoch:e=>{if(i.add(e),t)try{e(t.remote,t.epoch)}catch{}return()=>{i.delete(e)}},lastCall:()=>o,inFlight:()=>s}},bS=async()=>{if(typeof window<`u`)return vS;if(typeof self<`u`)return{receive:self,emit:self}},xS=yS({async*[Symbol.asyncIterator](){let e=await bS();if(!e){await new Promise(()=>{});return}yield*Iv({},{key:`fkn-api`,transport:e})}});xS.first.then(()=>xS.facade);var SS=xS.onEpoch;xS.current,xS.lastCall,xS.inFlight,SS(e=>{tS()&&e.overlay.setHost(sS,{exactClips:Dx()}).catch(()=>{})});var CS=new Set,wS=(e,t)=>{CS.add({kind:e,probe:t})},TS=`fkn-packages-connection`,ES=3e4,DS=(e,t)=>Object.assign(Error(t),{code:e}),OS=(e,t,n)=>Iv(e??{},{transport:t,key:TS,unregisterSignal:n}),kS=async(e,t,n={})=>{let{signal:r,closed:i}=n;if(r?.aborted)throw DS(`unavailable`,`packages.connect: aborted before connecting`);let a=new AbortController;r&&r.addEventListener(`abort`,()=>a.abort(r.reason),{once:!0});let o=new AbortController,s=new Promise((e,n)=>{let a=setTimeout(()=>n(DS(`timeout`,`packages.connect: the package did not complete the connection`)),ES);o.signal.addEventListener(`abort`,()=>clearTimeout(a),{once:!0}),t.addEventListener(`message`,e=>{if(e.data?.type===`fkn-packages-nack`){let t=e.data.message;n(DS(`unavailable`,typeof t==`string`&&t?t:`packages.connect: the package refused the connection`))}},{signal:o.signal}),t.start(),r&&r.addEventListener(`abort`,()=>n(DS(`unavailable`,`packages.connect: aborted before connecting`)),{once:!0,signal:o.signal}),i?.then(()=>n(DS(`unavailable`,`packages.connect: the package closed before connecting`)))});try{return await Promise.race([OS(e,t,a.signal),s])}catch(e){a.abort(e);try{t.close()}catch{}throw e}finally{o.abort()}},AS=new Map;wS(`package view`,()=>AS.size>0);var jS=(e,t,n)=>kS(t,e,{signal:n?.signal});let MS=function(e){return e.Html=`HTML`,e.Text=`TEXT`,e}({}),NS=function(e){return e.Html=`HTML`,e.Text=`TEXT`,e}({}),PS=function(e){return e.Cancelled=`CANCELLED`,e.Finished=`FINISHED`,e.Hiatus=`HIATUS`,e.NotYetReleased=`NOT_YET_RELEASED`,e.Releasing=`RELEASING`,e}({}),FS=function(e){return e.Anime=`ANIME`,e.LiveAction=`LIVE_ACTION`,e.Movie=`MOVIE`,e.Ona=`ONA`,e.Ova=`OVA`,e.Special=`SPECIAL`,e.Tv=`TV`,e.TvShort=`TV_SHORT`,e}({});const IS=e=>{let t=e[0];for(let n of e)t&&n.id.startsWith(`${t.id}-`)&&(t=n);return t},LS=(e,t)=>qS(e)?IS(ZS(e)?.handleUrisValues.filter(e=>e.origin===t)??[]):HS(e)&&RS(e).origin===t?RS(e):void 0,RS=e=>{let[t,n]=e.split(`:`);return{origin:t,id:n}},zS=(e,t)=>{let n=e.split(`,`).filter(Boolean).map(e=>RS(e));return t?n.find(({origin:e})=>e===t):n},BS=({origin:e,id:t})=>`${e}:${t}`,VS=e=>e.join(`,`),HS=e=>{let t=e.split(`:`).filter(e=>e.length);if(t[1]?.includes(`,`))throw Error(`Invalid uri: ${e}, contains "," character in id`);return t.length===2},US=/[,/()]/,WS=e=>{let t=e.indexOf(`:`);return t>0&&!US.test(e.slice(t+1))},GS=e=>e.split(`,`).every(HS),KS=/ag:\((.*)\)(?:-(.*))?/,qS=e=>{if(!e?.startsWith(`ag:`))return!1;let t=e.match(KS);if(!t)return!1;let n=t?.[1];return!n||GS(n)},JS=e=>{if(!e||HS(e)||qS(e))return e;try{let t=decodeURIComponent(e);return HS(t)||qS(t)?t:e}catch{return e}},YS=(e,t)=>`ag:(${XS(e)})${t?`-${t}`:``}`,XS=(e,t=!0)=>t?XS(zS(Array.isArray(e)?e.join(`,`):e).filter(e=>e.origin&&e.id).sort((e,t)=>e.id.localeCompare(t.id)).sort((e,t)=>e.origin.localeCompare(t.origin)).map(BS),!1):encodeURI(Array.isArray(e)?e.join(`,`):e),ZS=e=>{if(typeof e!=`string`)return;let t=e.match(KS);if(!t)return;let n=zS(t[1]).filter(e=>e.origin&&e.id).sort((e,t)=>e.id.localeCompare(t.id)).sort((e,t)=>e.origin.localeCompare(t.origin));return t&&{uri:`ag:(${VS(n.map(BS))})`,origin:`ag`,id:`(${VS(n.map(BS))})`,handleUris:n.map(BS),handleUrisString:VS(n.map(BS)),handleUrisValues:n,episodeId:t[2]}},QS=e=>qS(e)?[...new Set(ZS(e)?.handleUrisValues.map(e=>e.origin)??[])]:HS(e)?[RS(e).origin]:[];var $S=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,nC.unregister(this),e}free(){let e=this.__destroy_into_raw();B.__wbg_haystacks_free(e,0)}bytesView(){return B.haystacks_bytesView(this.__wbg_ptr)}clear(){B.haystacks_clear(this.__wbg_ptr)}commit(e,t){let n=B.haystacks_commit(this.__wbg_ptr,e,t);if(n[1])throw yC(n[0])}get length(){return B.haystacks_length(this.__wbg_ptr)>>>0}constructor(e){var t=gC(e)?0:_C(e,B.__wbindgen_malloc),n=wC;let r=B.haystacks_new(t,n);return this.__wbg_ptr=r,nC.register(this,this.__wbg_ptr,this),this}offsetsView(){return B.haystacks_offsetsView(this.__wbg_ptr)}push(e){let t=_C(e,B.__wbindgen_malloc),n=wC;B.haystacks_push(this.__wbg_ptr,t,n)}reserve(e,t){B.haystacks_reserve(this.__wbg_ptr,e,t)}};Symbol.dispose&&($S.prototype[Symbol.dispose]=$S.prototype.free);var eC=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,rC.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,rC.unregister(this),e}free(){let e=this.__destroy_into_raw();B.__wbg_matcher_free(e,0)}static fromPatterns(t,n){let r=B.matcher_fromPatterns(t,gC(n)?0:iC(n));if(r[2])throw yC(r[1]);return e.__wrap(r[0])}static fromQuery(t,n){let r=vC(t,B.__wbindgen_malloc,B.__wbindgen_realloc),i=wC,a=B.matcher_fromQuery(r,i,gC(n)?0:iC(n));if(a[2])throw yC(a[1]);return e.__wrap(a[0])}matchHaystacks(e){return aC(e,$S),B.matcher_matchHaystacks(this.__wbg_ptr,e.__wbg_ptr)}matchHaystacksIndices(e){return aC(e,$S),B.matcher_matchHaystacksIndices(this.__wbg_ptr,e.__wbg_ptr)}matchList(e){let t=_C(e,B.__wbindgen_malloc),n=wC;return B.matcher_matchList(this.__wbg_ptr,t,n)}matchListIndices(e){let t=_C(e,B.__wbindgen_malloc),n=wC;return B.matcher_matchListIndices(this.__wbg_ptr,t,n)}matchOne(e,t){let n=vC(e,B.__wbindgen_malloc,B.__wbindgen_realloc),r=wC;return B.matcher_matchOne(this.__wbg_ptr,n,r,t)}matchOneIndices(e,t){let n=vC(e,B.__wbindgen_malloc,B.__wbindgen_realloc),r=wC;return B.matcher_matchOneIndices(this.__wbg_ptr,n,r,t)}constructor(e,t){let n=vC(e,B.__wbindgen_malloc,B.__wbindgen_realloc),r=wC,i=B.matcher_new(n,r,gC(t)?0:iC(t));if(i[2])throw yC(i[1]);return this.__wbg_ptr=i[0],rC.register(this,this.__wbg_ptr,this),this}setConfig(e){let t=B.matcher_setConfig(this.__wbg_ptr,e);if(t[1])throw yC(t[0])}setPattern(e){let t=B.matcher_setPattern(this.__wbg_ptr,e);if(t[1])throw yC(t[0])}setPatterns(e){let t=B.matcher_setPatterns(this.__wbg_ptr,e);if(t[1])throw yC(t[0])}};Symbol.dispose&&(eC.prototype[Symbol.dispose]=eC.prototype.free);function tC(){return{__proto__:null,"./frizbee_wasm_bg.js":{__proto__:null,__wbg_Error_bce6d499ff0a4aff:function(e,t){return Error(uC(e,t))},__wbg___wbindgen_boolean_get_2304fb8c853028c8:function(e){let t=e,n=typeof t==`boolean`?t:void 0;return gC(n)?16777215:+!!n},__wbg___wbindgen_is_null_2042690d351e14f0:function(e){return e===null},__wbg___wbindgen_is_object_b4593df85baada48:function(e){let t=e;return typeof t==`object`&&!!t},__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5:function(e){return e===void 0},__wbg___wbindgen_number_get_f73a1244370fcc2c:function(e,t){let n=t,r=typeof n==`number`?n:void 0;lC().setFloat64(e+8,gC(r)?0:r,!0),lC().setInt32(e+0,!gC(r),!0)},__wbg___wbindgen_string_get_d109740c0d18f4d7:function(e,t){let n=t,r=typeof n==`string`?n:void 0;var i=gC(r)?0:vC(r,B.__wbindgen_malloc,B.__wbindgen_realloc),a=wC;lC().setInt32(e+4,a,!0),lC().setInt32(e+0,i,!0)},__wbg___wbindgen_throw_9c31b086c2b26051:function(e,t){throw Error(uC(e,t))},__wbg_from_fa561fa561dc8031:function(e){return Array.from(e)},__wbg_get_dcf82ab8aad1a593:function(){return hC(function(e,t){return Reflect.get(e,t)},arguments)},__wbg_get_unchecked_1dfe6d05ad91d9b7:function(e,t){return e[t>>>0]},__wbg_isArray_94898ed3aad6947b:function(e){return Array.isArray(e)},__wbg_length_2591a0f4f659a55c:function(e){return e.length},__wbg_new_02d162bc6cf02f60:function(){return{}},__wbg_new_310879b66b6e95e1:function(){return[]},__wbg_new_with_length_c2a8f9ac6aaaac03:function(e){return Array(e>>>0)},__wbg_push_b77c476b01548d0a:function(e,t){return e.push(t)},__wbg_set_78ea6a19f4818587:function(e,t,n){e[t>>>0]=n},__wbg_set_a0e911be3da02782:function(){return hC(function(e,t,n){return Reflect.set(e,t,n)},arguments)},__wbindgen_cast_0000000000000001:function(e){return e},__wbindgen_cast_0000000000000002:function(e,t){return oC(e,t)},__wbindgen_cast_0000000000000003:function(e,t){return sC(e,t)},__wbindgen_cast_0000000000000004:function(e,t){return uC(e,t)},__wbindgen_init_externref_table:function(){let e=B.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const nC=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>B.__wbg_haystacks_free(e,1)),rC=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>B.__wbg_matcher_free(e,1));function iC(e){let t=B.__externref_table_alloc();return B.__wbindgen_externrefs.set(t,e),t}function aC(e,t){if(!(e instanceof t))throw Error(`expected instance of ${t.name}`)}function oC(e,t){return e>>>=0,fC().subarray(e/4,e/4+t)}function sC(e,t){return e>>>=0,mC().subarray(e/1,e/1+t)}let cC=null;function lC(){return(cC===null||cC.buffer.detached===!0||cC.buffer.detached===void 0&&cC.buffer!==B.memory.buffer)&&(cC=new DataView(B.memory.buffer)),cC}function uC(e,t){return SC(e>>>0,t)}let dC=null;function fC(){return(dC===null||dC.byteLength===0)&&(dC=new Uint32Array(B.memory.buffer)),dC}let pC=null;function mC(){return(pC===null||pC.byteLength===0)&&(pC=new Uint8Array(B.memory.buffer)),pC}function hC(e,t){try{return e.apply(this,t)}catch(e){let t=iC(e);B.__wbindgen_exn_store(t)}}function gC(e){return e==null}function _C(e,t){let n=t(e.length*4,4)>>>0;for(let t=0;t<e.length;t++){let r=iC(e[t]);lC().setUint32(n+4*t,r,!0)}return wC=e.length,n}function vC(e,t,n){if(n===void 0){let n=CC.encode(e),r=t(n.length,1)>>>0;return mC().subarray(r,r+n.length).set(n),wC=n.length,r}let r=e.length,i=t(r,1)>>>0,a=mC(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=mC().subarray(i+o,i+r),a=CC.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return wC=o,i}function yC(e){let t=B.__wbindgen_externrefs.get(e);return B.__externref_table_dealloc(e),t}let bC=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});bC.decode();let xC=0;function SC(e,t){return xC+=t,xC>=2146435072&&(bC=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),bC.decode(),xC=t),bC.decode(mC().subarray(e,e+t))}const CC=new TextEncoder;`encodeInto`in CC||(CC.encodeInto=function(e,t){let n=CC.encode(e);return t.set(n),{read:e.length,written:n.length}});let wC=0,B;function TC(e,t){return B=e.exports,cC=null,dC=null,pC=null,B.__wbindgen_start(),B}async function EC(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function DC(e){if(B!==void 0)return B;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`)),e===void 0&&(e=new URL(`/assets/frizbee_wasm_bg-FO8dlm9E.wasm`,``+import.meta.url));let t=tC();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await EC(await e,t);return TC(n,r)}const OC=new TextEncoder;function kC(e,t){let n=0;for(let e of t)n+=e.length*3;e.reserve(n,t.length);let r=e.bytesView(),i=e.offsetsView(),a=0;for(let e=0;e<t.length;e++)a+=OC.encodeInto(t[e],r.subarray(a)).written,i[e]=a;return e.commit(a,t.length),e}var AC=class extends $S{constructor(e){super(),e?.length&&kC(this,e)}push(e){kC(this,e)}};let jC;function MC(e){return jC??=new AC,jC.clear(),kC(jC,e)}eC.prototype.matchList=function(e){return this.matchHaystacks(e instanceof $S?e:MC(e))},eC.prototype.matchListIndices=function(e){return this.matchHaystacksIndices(e instanceof $S?e:MC(e))};var NC=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,IC.unregister(this),e}free(){let e=this.__destroy_into_raw();V.__wbg_releaseindex_free(e,0)}get len(){return V.releaseindex_len(this.__wbg_ptr)>>>0}constructor(e){let t=QC(e,V.__wbindgen_export),n=aw,r=V.releaseindex_new(t,n);return this.__wbg_ptr=r>>>0,IC.register(this,this.__wbg_ptr,this),this}parsed(e){try{let r=V.__wbindgen_add_to_stack_pointer(-16);V.releaseindex_parsed(r,this.__wbg_ptr,e);var t=VC().getInt32(r+0,!0),n=VC().getInt32(r+4,!0);if(VC().getInt32(r+8,!0))throw ew(n);return ew(t)}finally{V.__wbindgen_add_to_stack_pointer(16)}}search(e,t){try{let i=V.__wbindgen_add_to_stack_pointer(-16),a=QC(e,V.__wbindgen_export),o=aw;V.releaseindex_search(i,this.__wbg_ptr,a,o,ZC(t)?0:LC(t));var n=VC().getInt32(i+0,!0),r=VC().getInt32(i+4,!0);if(VC().getInt32(i+8,!0))throw ew(r);return ew(n)}finally{V.__wbindgen_add_to_stack_pointer(16)}}titleMatches(e,t){try{let i=V.__wbindgen_add_to_stack_pointer(-16),a=QC(e,V.__wbindgen_export),o=aw;V.releaseindex_titleMatches(i,this.__wbg_ptr,a,o,ZC(t)?4294967297:Math.fround(t));var n=VC().getInt32(i+0,!0),r=VC().getInt32(i+4,!0);if(VC().getInt32(i+8,!0))throw ew(r);return ew(n)}finally{V.__wbindgen_add_to_stack_pointer(16)}}titleScores(e){try{let i=V.__wbindgen_add_to_stack_pointer(-16),a=QC(e,V.__wbindgen_export),o=aw;V.releaseindex_titleScores(i,this.__wbg_ptr,a,o);var t=VC().getInt32(i+0,!0),n=VC().getInt32(i+4,!0),r=zC(t,n).slice();return V.__wbindgen_export4(t,n*4,4),r}finally{V.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(NC.prototype[Symbol.dispose]=NC.prototype.free);function PC(e){try{let r=V.__wbindgen_add_to_stack_pointer(-16),i=$C(e,V.__wbindgen_export,V.__wbindgen_export2),a=aw;V.parse(r,i,a);var t=VC().getInt32(r+0,!0),n=VC().getInt32(r+4,!0);if(VC().getInt32(r+8,!0))throw ew(n);return ew(t)}finally{V.__wbindgen_add_to_stack_pointer(16)}}function FC(){return{__proto__:null,"./sacha_bg.js":{__proto__:null,__wbg_String_8564e559799eccda:function(e,t){let n=$C(String(qC(t)),V.__wbindgen_export,V.__wbindgen_export2),r=aw;VC().setInt32(e+4,r,!0),VC().setInt32(e+0,n,!0)},__wbg___wbindgen_is_null_0b605fc6b167c56f:function(e){return qC(e)===null},__wbg___wbindgen_is_undefined_52709e72fb9f179c:function(e){return qC(e)===void 0},__wbg___wbindgen_number_get_34bb9d9dcfa21373:function(e,t){let n=qC(t),r=typeof n==`number`?n:void 0;VC().setFloat64(e+8,ZC(r)?0:r,!0),VC().setInt32(e+0,!ZC(r),!0)},__wbg___wbindgen_string_get_395e606bd0ee4427:function(e,t){let n=qC(t),r=typeof n==`string`?n:void 0;var i=ZC(r)?0:$C(r,V.__wbindgen_export,V.__wbindgen_export2),a=aw;VC().setInt32(e+4,a,!0),VC().setInt32(e+0,i,!0)},__wbg___wbindgen_throw_6ddd609b62940d55:function(e,t){throw Error(WC(e,t))},__wbg_get_3ef1eba1850ade27:function(){return JC(function(e,t){return LC(Reflect.get(qC(e),qC(t)))},arguments)},__wbg_new_a70fbab9066b301f:function(){return LC([])},__wbg_new_ab79df5bd7c26067:function(){return LC({})},__wbg_set_282384002438957f:function(e,t,n){qC(e)[t>>>0]=ew(n)},__wbg_set_6be42768c690e380:function(e,t,n){qC(e)[ew(t)]=ew(n)},__wbindgen_cast_0000000000000001:function(e){return LC(e)},__wbindgen_cast_0000000000000002:function(e,t){return LC(WC(e,t))},__wbindgen_object_clone_ref:function(e){return LC(qC(e))},__wbindgen_object_drop_ref:function(e){ew(e)}}}}const IC=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>V.__wbg_releaseindex_free(e>>>0,1));function LC(e){XC===YC.length&&YC.push(YC.length+1);let t=XC;return XC=YC[t],YC[t]=e,t}function RC(e){e<1028||(YC[e]=XC,XC=e)}function zC(e,t){return e>>>=0,UC().subarray(e/4,e/4+t)}let BC=null;function VC(){return(BC===null||BC.buffer.detached===!0||BC.buffer.detached===void 0&&BC.buffer!==V.memory.buffer)&&(BC=new DataView(V.memory.buffer)),BC}let HC=null;function UC(){return(HC===null||HC.byteLength===0)&&(HC=new Float32Array(V.memory.buffer)),HC}function WC(e,t){return e>>>=0,rw(e,t)}let GC=null;function KC(){return(GC===null||GC.byteLength===0)&&(GC=new Uint8Array(V.memory.buffer)),GC}function qC(e){return YC[e]}function JC(e,t){try{return e.apply(this,t)}catch(e){V.__wbindgen_export3(LC(e))}}let YC=Array(1024).fill(void 0);YC.push(void 0,null,!0,!1);let XC=YC.length;function ZC(e){return e==null}function QC(e,t){let n=t(e.length*4,4)>>>0,r=VC();for(let t=0;t<e.length;t++)r.setUint32(n+4*t,LC(e[t]),!0);return aw=e.length,n}function $C(e,t,n){if(n===void 0){let n=iw.encode(e),r=t(n.length,1)>>>0;return KC().subarray(r,r+n.length).set(n),aw=n.length,r}let r=e.length,i=t(r,1)>>>0,a=KC(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=KC().subarray(i+o,i+r),a=iw.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return aw=o,i}function ew(e){let t=qC(e);return RC(e),t}let tw=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});tw.decode();let nw=0;function rw(e,t){return nw+=t,nw>=2146435072&&(tw=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),tw.decode(),nw=t),tw.decode(KC().subarray(e,e+t))}const iw=new TextEncoder;`encodeInto`in iw||(iw.encodeInto=function(e,t){let n=iw.encode(e);return t.set(n),{read:e.length,written:n.length}});let aw=0,V;function ow(e,t){return V=e.exports,BC=null,HC=null,GC=null,V}async function sw(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function cw(e){if(V!==void 0)return V;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`)),e===void 0&&(e=new URL(`/assets/sacha_bg-CNH7LeJ_.wasm`,``+import.meta.url));let t=FC();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await sw(await e,t);return ow(n,r)}const lw=`season-seed.json.gz`,uw=`season-seed-episodes.json.gz`,dw=e=>`https://github.com/banou26/stub/releases/download/season-seed/${e}`,fw=/^\d{4}-(WINTER|SPRING|SUMMER|FALL)$/,pw=/^(mal|anilist|kitsu)-\d+$/,mw=/^[a-z0-9]+$/,hw=/[,/()]/,gw=/^https?:\/\//,_w=/^[0-9a-f]{7,40}$/,vw=[`TV`,`TV_SHORT`,`MOVIE`,`ANIME`,`SPECIAL`,`OVA`,`ONA`,`LIVE_ACTION`],yw=[`ANIME`,`SERIES`,`MOVIE`],bw=e=>e.replace(`-`,`:`),xw=`offline`,Sw=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Cw=e=>typeof e==`string`&&e.length>0,ww=e=>e===null||typeof e==`number`&&Number.isFinite(e),Tw=e=>e===null||typeof e==`string`,Ew=e=>e.length<=50?e:[...e.slice(0,50),`... and ${e.length-50} more`],Dw=(e,t)=>e.startsWith(`${t}-`)||t.startsWith(`${e}-`),Ow=(e,t,n,r,i)=>{if(!Sw(e)){i.push(`run ${t}: ${n} entry is not an object`);return}let{uri:a,origin:o,id:s,scope:c}=e;if(!Cw(a)||!Cw(o)||!Cw(s)||a!==`${o}:${s}`||!mw.test(o)){i.push(`run ${t}: ${n} uri ${JSON.stringify(a)} is not <origin>:<id>`);return}hw.test(s)&&i.push(`run ${t}: ${n} id ${JSON.stringify(s)} is not routable`),c!==r&&i.push(`run ${t}: ${n} ${a} scope ${JSON.stringify(c)}, expected ${r}`),o===xw&&i.push(`run ${t}: ${n} member ${a} is of origin ${xw}`)},kw=(e,t,n,r)=>{if(!Array.isArray(e)){r.push(`${t}: titles is not an array`);return}e.length>n&&r.push(`${t}: ${e.length} titles over the cap of ${n}`);for(let n of e)(!Sw(n)||!Cw(n.language)||!Cw(n.title))&&r.push(`${t}: title ${JSON.stringify(n)} needs a non-empty language and title`)},Aw=(e,t,n,r,i)=>{if(!Array.isArray(e)){i.push(`${t}: ${n}s is not an array`);return}e.length>r&&i.push(`${t}: ${e.length} ${n}s over the cap of ${r}`);for(let r of e)(!Sw(r)||!Cw(r.url)||!gw.test(r.url)||!Tw(r.language))&&i.push(`${t}: ${n} ${JSON.stringify(Sw(r)?r.url:r)} is not an http url`)},jw=(e,t,n,r)=>{if(!Sw(e)){r.push(`runs[${t}]: not an object`);return}let i=e,a=Cw(i.key)?i.key:`runs[${t}]`,o=Array.isArray(i.identity)?i.identity:[],s=`run ${a}`;!Cw(i.key)||!pw.test(i.key)?r.push(`${s}: key ${JSON.stringify(i.key)} is not <mal|anilist|kitsu>-<digits>`):o.some(e=>Sw(e)&&e.uri===bw(i.key))||r.push(`${s}: key names no identity member (${bw(i.key)})`),Array.isArray(i.identity)?i.identity.length||r.push(`${s}: identity is empty`):r.push(`${s}: identity is not an array`);for(let e of o)Ow(e,a,`identity`,`RUN`,r);Array.isArray(i.containers)||r.push(`${s}: containers is not an array`);for(let e of Array.isArray(i.containers)?i.containers:[])Ow(e,a,`containers`,`CONTAINER`,r);for(let e of o){if(!Sw(e)||!Cw(e.uri))continue;let t=n.identity.get(e.uri);t?r.push(`${e.uri} is in the identity of both ${t} and ${a}`):n.identity.set(e.uri,a)}for(let e of Array.isArray(i.containers)?i.containers:[])!Sw(e)||!Cw(e.uri)||n.containers.has(e.uri)||n.containers.set(e.uri,a);kw(i.titles,s,1,r),Aw(i.covers,s,`cover`,3,r),Aw(i.banners,s,`banner`,2,r),i.type!==null&&!vw.includes(i.type)&&r.push(`${s}: type ${JSON.stringify(i.type)} is not a media type`),(!Array.isArray(i.categories)||i.categories.some(e=>!yw.includes(e)))&&r.push(`${s}: categories ${JSON.stringify(i.categories)} are not media categories`),ww(i.episodeCount)||r.push(`${s}: episodeCount is neither a number nor null`),ww(i.averageScore)||r.push(`${s}: averageScore is neither a number nor null`),ww(i.popularity)||r.push(`${s}: popularity is neither a number nor null`),i.isAdult!==null&&typeof i.isAdult!=`boolean`&&r.push(`${s}: isAdult is neither a boolean nor null`),i.season!==null&&!(Cw(i.season)&&fw.test(i.season))&&r.push(`${s}: season ${JSON.stringify(i.season)} is not a season key`)},Mw=e=>{if(!Sw(e))return[`seed: not an object`];let t=[],n=e;if(n.version!==1&&t.push(`seed: version ${JSON.stringify(n.version)}, expected 1`),(!Cw(n.generatedAt)||!Number.isFinite(Date.parse(n.generatedAt)))&&t.push(`seed: generatedAt ${JSON.stringify(n.generatedAt)} is not a date`),(!Cw(n.commit)||!_w.test(n.commit))&&t.push(`seed: commit ${JSON.stringify(n.commit)} is not a sha`),!Array.isArray(n.runs))return t.push(`seed: runs is not an array`),Ew(t);let r={identity:new Map,containers:new Map};n.runs.forEach((e,n)=>jw(e,n,r,t));for(let[e,n]of r.identity){let i=r.containers.get(e);i&&t.push(`${e} is a RUN member of ${n} and a CONTAINER of ${i}`)}let i=new Set(n.runs.map(e=>Sw(e)?e.key:void 0).filter(Cw)),a=new Map;if(!Sw(n.seasons))t.push(`seed: seasons is not an object`);else{for(let[e,r]of Object.entries(n.seasons)){if(fw.test(e)||t.push(`seasons: ${JSON.stringify(e)} is not a season key`),!Array.isArray(r)){t.push(`seasons ${e}: not an array of run keys`);continue}for(let n of r)!Cw(n)||!i.has(n)?t.push(`seasons ${e}: names ${JSON.stringify(n)}, which is not a run`):a.has(n)||a.set(n,e)}for(let e of n.runs){if(!Sw(e)||!Cw(e.key))continue;let n=a.get(e.key)??null;(e.season??null)!==n&&t.push(`run ${e.key}: season ${JSON.stringify(e.season)}, expected ${JSON.stringify(n)}`)}}return Ew(t)},Nw=e=>Mw(e).length===0,Pw=(e,t,n)=>{if(!Sw(e)){n.push(`${t}: not an object`);return}let r=e;if(kw(r.titles,t,2,n),Aw(r.thumbnails,t,`thumbnail`,1,n),!Array.isArray(r.urls))n.push(`${t}: urls is not an array`);else{r.urls.length>2&&n.push(`${t}: ${r.urls.length} urls over the cap of 2`);let e=new Set,i=!1;for(let a of r.urls){if(!Sw(a)||!Cw(a.origin)||!Cw(a.url)||!gw.test(a.url)){n.push(`${t}: url ${JSON.stringify(a)} needs an origin and an http url`);continue}a.origin===xw&&n.push(`${t}: url ${a.url} is of origin ${xw}`),e.has(a.origin)&&!i&&(i=!0,n.push(`${t}: two urls of origin ${a.origin}`)),e.add(a.origin)}}Tw(r.releaseDate)||n.push(`${t}: releaseDate is neither a string nor null`),ww(r.seasonNumber)||n.push(`${t}: seasonNumber is neither a number nor null`),ww(r.absoluteEpisodeNumber)||n.push(`${t}: absoluteEpisodeNumber is neither a number nor null`),ww(r.runtime)||n.push(`${t}: runtime is neither a number nor null`)},Fw=(e,t)=>{if(!Sw(e))return[`seed episodes: not an object`];let n=[],r=e;if(r.version!==1&&n.push(`seed episodes: version ${JSON.stringify(r.version)}, expected 1`),r.generatedAt!==t.generatedAt&&n.push(`seed episodes: generatedAt ${JSON.stringify(r.generatedAt)} is not the index's ${JSON.stringify(t.generatedAt)}`),r.commit!==t.commit&&n.push(`seed episodes: commit ${JSON.stringify(r.commit)} is not the index's ${JSON.stringify(t.commit)}`),!Sw(r.episodes))return n.push(`seed episodes: episodes is not an object`),Ew(n);let i=new Set((t.runs??[]).map(e=>e?.key));for(let[e,t]of Object.entries(r.episodes)){if(i.has(e)||n.push(`seed episodes ${e}: names no run in the index`),!Array.isArray(t)){n.push(`seed episodes ${e}: not an array`);continue}t.length>60&&n.push(`seed episodes ${e}: ${t.length} episodes over the cap of 60`);let r=0;for(let[i,a]of t.entries()){let t=Sw(a)?a.number:void 0;if(typeof t!=`number`||!Number.isFinite(t)||t<=r){n.push(`seed episodes ${e}: number ${JSON.stringify(t)} at ${i} is not ascending and positive`);break}r=t}for(let r of t)Pw(r,`seed episodes ${e}`,n)}return Ew(n)},Iw=(e,t)=>Fw(e,t).length===0,Lw=[`winter`,`spring`,`summer`,`fall`],Rw=(e=new Date)=>({season:Lw[Math.floor(e.getMonth()/3)],year:e.getFullYear()}),zw=[`WINTER`,`SPRING`,`SUMMER`,`FALL`],Bw=e=>e.toUpperCase(),Vw=e=>Lw.find(t=>t===e.toLowerCase()),Hw=(e=new Date)=>{let{season:t,year:n}=Rw(e);return{season:Bw(t),year:n}},Uw={〇:0,零:0,一:1,二:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},Ww=e=>{if(/^\d+$/.test(e))return Number(e);let t=0,n=0;for(let r of e){if(r===`十`){t+=(n||1)*10,n=0;continue}let e=Uw[r];if(e===void 0)return;n=e}return t+n||void 0},Gw=[/\b(\d{1,3})(?:st|nd|rd|th)\s+(?:season|part|cour)\b/i,/\b(?:season|part|cour)\s*(\d{1,3})\b/i,/シーズン\s*(\d{1,3})/,/第\s*([\d〇零一二三四五六七八九十]{1,4})\s*[期季]/,/(\d{1,3})\s*[期기]/,/\bS(\d{1,2})\b/],Kw=[/\s*\b(?:(?:season|part|pt\.?|cour)\s*\d{1,3}|\d{1,3}(?:st|nd|rd|th)\s+(?:season|part|pt\.?|cour)|(?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth)\s+(?:season|part|pt\.?|cour))\b/gi,/\s*(?:シーズン\s*\d{1,3}|第\s*[\d〇零一二三四五六七八九十]{1,4}\s*[期季])/g],qw=/\p{L}/u,Jw=e=>!qw.test(Kw.reduce((e,t)=>e.replace(t,` `),e)),Yw=e=>{for(let t of Gw){let n=t.exec(e);if(n){let e=Ww(n[1]);if(e!==void 0)return e}}},Xw=(e,t)=>{if(e.length<=1)return;let n=e.filter(e=>e.episodeCount===t);return n.length===1?n[0].seasonNumber:void 0},Zw=/^(.+)-s(\d{1,3})$/,Qw=(e,t)=>`${e}-s${t}`,$w=e=>{let t=Zw.exec(e);return t?{showId:t[1],seasonNumber:Number(t[2])}:{showId:e}},eT=e=>{if(!e)return!1;let t=new Date(e);return Number.isNaN(t.getTime())?!1:t.getUTCDate()!==1},tT=e=>`node`in e,nT=e=>`node`in e,rT=e=>({node:e,relation:`SAME_AS`}),iT=e=>({node:{...e,scope:`CONTAINER`},relation:`PART_OF`}),aT=e=>({node:e,relation:`SAME_AS`}),H=({origin:e,id:t,handles:n,...r})=>({_id:crypto.randomUUID(),uri:BS({origin:e,id:t}),origin:e,id:t,url:void 0,scope:`RUN`,handles:(n??[]).map(e=>tT(e)?e:rT(e)),relations:[],categories:[],genres:[],tags:[],titles:[],descriptions:[],shortDescriptions:[],covers:[],banners:[],episodes:[],trailers:[],...r}),oT=({origin:e,id:t,mediaUri:n,handles:r,...i})=>({_id:crypto.randomUUID(),uri:BS({origin:e,id:t}),origin:e,id:t,url:void 0,mediaUri:n,handles:(r??[]).map(e=>nT(e)?e:aT(e)),titles:[],descriptions:[],shortDescriptions:[],thumbnails:[],...i}),sT=(e,t={})=>oT({origin:e.origin,id:`${e.id}-1`,mediaUri:e.uri,url:e.url,score:e.score??void 0,titles:(e.titles??[]).map(({language:e,title:t,score:n})=>({language:e,title:t,score:n})),descriptions:(e.descriptions??[]).map(({language:e,description:t,score:n})=>({language:e,description:t,score:n})),shortDescriptions:(e.shortDescriptions??[]).map(({language:e,shortDescription:t,score:n})=>({language:e,shortDescription:t,score:n})),thumbnails:(e.covers??[]).map(({url:e,score:t})=>({url:e,score:t})),episodeNumber:1,...t}),cT=e=>!!e.categories?.includes(`MOVIE`),lT=async(e,t,n)=>{let r=await Promise.allSettled(e.map(async e=>t(e))),i=[];for(let e of r)e.status===`fulfilled`?i.push(e.value):console.error(`${n}: dropped a record that failed to normalize`,e.reason);return i},uT=(e,t)=>e?{descriptions:[{language:`en`,description:e,score:t}],shortDescriptions:[{language:`en`,shortDescription:e,score:t}]}:{},dT=(e,t)=>e?[{url:e,score:t}]:[],fT=e=>e?.titles?.[0]?.title,pT=e=>e?.episodeCount??void 0,mT=e=>e.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu,``).replace(/\s+/g,` `).trim();let hT;const gT=()=>hT??=DC();let _T;const vT=()=>_T??=cw(),yT={maxTypos:1/0,casing:`ignore`,unicode:`always`};let bT;const xT=(e,t)=>(bT?bT.setPattern(e):bT=new eC(e,yT),bT.matchOne(t,0)?.score??0);let ST;const CT=(e,t)=>{let n={...yT,maxTypos:0,matching:`substring`};return ST?ST.setPattern(e):ST=new eC(e,n),(ST.matchOne(t,0)?.score??0)>0},wT=new Map,TT=e=>{let t=wT.get(e);if(t!==void 0)return t;let n=xT(e,e);return wT.set(e,n),n},ET=async(e,t)=>{let n=mT(e),r=mT(t);if(!n||!r)return 0;await gT();let i=TT(n),a=TT(r);return!i||!a?0:Math.min(xT(n,r)/i,xT(r,n)/a)},DT=async(e,t)=>{let n=mT(e),r=mT(t);if(!n||!r)return 0;if(await gT(),CT(n,r))return 1;let i=TT(n);return i?Math.min(1,xT(n,r)/i):0},OT=async(e,t)=>t.length?Math.max(...await Promise.all(t.map(t=>DT(e,t)))):0,kT=async(e,t)=>{let n=await LT(t),r=await Promise.all(e.filter(e=>!!e?.trim()).map(async e=>ET(await LT(e),n)));return r.length?Math.max(...r):0},AT=async(e,t,n)=>{let r;for(let i of t){if(n?.length&&i.categories?.length&&!n.some(e=>i.categories.includes(e)))continue;let t=await ET(e,i.title);t<.44||(!r||t>r.score)&&(r={candidate:i,score:t})}return r?.candidate},jT=`\\u002d\\u2013\\u2014\\u007e\\uff5e\\u301c`,MT=RegExp(`(?:^|\\s)([${jT}])\\s*[^${jT}]{2,}\\s*\\1\\s*$`),NT=/\b(?:the|a|an)\b/gi,PT=e=>e.replace(/\s+/g,` `).trim(),FT=e=>{let t=MT.exec(e);return t?PT(e.slice(0,t.index)):e},IT=e=>PT(Kw.reduce((e,t)=>e.replace(t,` `),e)),LT=async e=>{if(!e.trim())return e;await vT();try{return PC(e).titles?.[0]??e}catch{return e}},RT=e=>PT(e.replace(NT,` `)),zT=e=>{let t=e.indexOf(`:`);return t>2?e.slice(0,t).trim():e},BT=e=>{let t=new Set([e]),n=[],r=e;for(let e of[FT,IT,RT,zT])r=e(r),!(r.length<3||t.has(r))&&(t.add(r),n.push(r));return n},VT=(e,t)=>{let n=ZS(e);if(!n)return[];let r=new Map;for(let{origin:e,id:i}of n.handleUrisValues)e!==t&&r.set(e,[...r.get(e)??[],i]);let i=[];for(let[e,t]of r){let[n,...r]=[...new Set(t)].filter(e=>!t.some(t=>Dw(t,e)&&t.startsWith(`${e}-`)));!n||r.length||i.push({...rT(H({origin:e,id:n})),provenance:`address`})}return i},HT=(e,t)=>{let n=VT(t,e.origin),r=new Set(e.handles.map(e=>`${e.node.origin}\0${e.relation}`));e.handles=[...e.handles,...n.filter(e=>!r.has(`${e.node.origin}\0${e.relation}`))]},UT=async(e,t,n,r=15e3)=>{let i=n(await t.findAggregatedMedia(e));if(i)return i;let a=new AbortController,o=setTimeout(()=>a.abort(),r);try{for await(let r of t.listenForMediaChanges({uri:e},{abortSignal:a.signal})){let r=n(await t.findAggregatedMedia(e));if(r)return r}}finally{clearTimeout(o),a.abort()}},WT=/^(https:\/\/cdn\.myanimelist\.net\/images\/anime\/[^/]+\/\d+)[a-z]?(\.\w+)(\?.*)?$/,GT=e=>{let t=e?.match(WT);return t?`${t[1]}l${t[2]}${t[3]??``}`:e},KT=e=>e.section===`TV (Continuing)`,qT={1:`TV`,2:`OVA`,3:`MOVIE`,4:`SPECIAL`,5:`ONA`,6:`MUSIC`,9:`SPECIAL`},JT=e=>{if(!e||!/^\d{8}$/.test(e))return;let[t,n,r]=[e.slice(0,4),e.slice(4,6),e.slice(6,8)];if(!(n===`00`||r===`00`))return`${t}-${n}-${r}`},YT=e=>e.replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&#0?39;/g,`'`).replace(/&nbsp;/g,` `).replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(Number(t))),XT=e=>{if(e)return YT(e.replace(/<[^>]*>/g,` `)).replace(/\s+/g,` `).trim()||void 0},ZT=e=>{if(!e)return;let t=Number(e.replace(/,/g,``));return Number.isFinite(t)?t:void 0},QT=(e,t)=>t.exec(e)?.[1],$T=e=>{let t=[];for(let n of e.matchAll(/<a[^>]+href="\/anime\/genre\/\d+\/[^"]*"[^>]*title="([^"]+)"/g)){let e=XT(n[1]);e&&!t.includes(e)&&t.push(e)}return t},eE=e=>{let t=[...e.matchAll(/class="anime-header">([^<]*)</g)];return t.length?t.map((n,r)=>({name:XT(n[1])??``,body:e.slice(n.index??0,t[r+1]?.index??e.length)})):[{name:``,body:e}]},tE=e=>{let t=[],n=new Set;for(let r of eE(e))for(let e of r.body.split(`js-anime-category-producer`).slice(1)){let i=QT(e,/myanimelist\.net\/anime\/(\d+)/)??QT(e,/class="genres js-genre" id="(\d+)"/),a=XT(QT(e,/class="link-title">([^<]+)</));if(!i||!a||n.has(i))continue;n.add(i);let o=QT(e,/<img[^>]*\bdata-src="(https:\/\/cdn\.myanimelist\.net\/images\/anime\/[^"]+)"/)??QT(e,/<img[^>]*\bsrc="(https:\/\/cdn\.myanimelist\.net\/images\/anime\/[^"]+)"/);t.push({id:i,title:a,englishTitle:XT(QT(e,/class="h3_anime_subtitle">([^<]*)</)),cover:GT(o),synopsis:XT(QT(e,/class="preline">([\s\S]*?)<\/p>/)),score:ZT(QT(e,/class="js-score">([\d.]+)</)),members:ZT(QT(e,/class="js-members">([\d,]+)</)),episodes:ZT(QT(e,/<span>\s*(\d+)\s*eps?\s*<\/span>/)),startDate:JT(QT(e,/class="js-start_date">(\d+)</)),typeId:ZT(QT(e,/js-anime-type-(\d+)/)),section:r.name,genres:$T(e)})}return t},nE=(e,t)=>{let n=typeof e==`string`?Number(e):e;if(n==null||!Number.isFinite(n)||n<=0)return;let r=Math.round(t===10?n*10:n);return r>0&&r<=100?r:void 0};var rE=c({anidbIdFromUrl:()=>pE,categories:()=>oE,icon:()=>iE,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>sE,official:()=>!0,origin:()=>`mal`,originUrl:()=>aE,resolvers:()=>TE,supportedUris:()=>cE});const iE=`https://cdn.myanimelist.net/images/favicon.ico`,aE=`https://myanimelist.net`,oE=[`ANIME`,`SERIES`,`MOVIE`],sE=`MyAnimeList`,cE=[`mal`],lE={spread:!0},uE=.9,dE=.9,fE=/\/embed\/([a-zA-Z0-9_-]{11})/,pE=e=>{if(e)try{let{searchParams:t,pathname:n}=new URL(e),r=t.get(`aid`)??/^\/anime\/([^/?#]+)/.exec(n)?.[1];return r&&/^\d+$/.test(r)?r:void 0}catch{return}},mE=e=>{let t=new Set,n=[];for(let r of[...e.genres??[],...e.themes??[],...e.demographics??[]]){let e=r?.name;!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n},hE=async(e,t)=>{let n=e.external?.find(e=>e.name===`AniDB`),r=pE(n?.url),i=r?{_id:crypto.randomUUID(),uri:`anidb:${r}`,origin:`anidb`,id:r,url:n?.url}:void 0,a=r?{_id:crypto.randomUUID(),uri:`anizip:${r}`,origin:`anizip`,id:r,url:`https://api.ani.zip/mappings?anidb_id=${r}`}:void 0,o=e.trailer?.embed_url?e.trailer.embed_url.match(fE)?.[1]:void 0,s=e.trailer?.youtube_id?[{uri:`yt:${e.trailer.youtube_id}`,origin:`yt`,id:e.trailer.youtube_id,url:`https://www.youtube.com/watch?v=${e.trailer.youtube_id}`,language:`en`,thumbnail:e.trailer.images.image_url}]:e.trailer?.embed_url&&o?[{uri:`yt:${o}`,origin:`yt`,id:o,url:`https://www.youtube.com/watch?v=${o}`,language:`en`,thumbnail:e.trailer.images.image_url}]:[],c=e.season?Vw(e.season):void 0;return{_id:crypto.randomUUID(),uri:`mal:${e.mal_id}`,origin:`mal`,categories:e.type===`Movie`?[`ANIME`,`MOVIE`]:[`ANIME`,`SERIES`],type:e.type===`TV`?FS.Tv:e.type===`Movie`?FS.Movie:e.type===`Special`?FS.Special:e.type===`OVA`?FS.Ova:e.type===`ONA`?FS.Ona:void 0,id:e.mal_id.toString(),url:e.url,handles:[...i?[rT(i)]:[],...a?[rT(a)]:[]],score:uE,averageScore:nE(e.score,10),descriptions:e.synopsis?[{language:`en`,description:e.synopsis,score:dE}]:[],shortDescriptions:e.synopsis?[{language:`en`,shortDescription:e.synopsis,score:dE}]:[],titles:[...e.title_english?[{language:`en`,title:e.title_english,score:uE}]:[],...e.title?[{language:`jp-en`,title:e.title,score:uE}]:[],...e.title_japanese?[{language:`jp`,title:e.title_japanese,score:uE}]:[]],covers:[{language:`en`,url:GT(e.images.webp.large_image_url),score:uE}],banners:[],episodes:[],episodeCount:e.episodes,popularity:e.members,genres:mE(e),tags:[],status:e.status===`Not yet aired`?PS.NotYetReleased:e.status===`Currently Airing`?PS.Releasing:e.status===`Finished Airing`?PS.Finished:void 0,season:c?Bw(c):null,seasonYear:e.year??null,startDate:e.aired?.from??null,endDate:e.aired?.to??null,trailers:s,relations:[]}},gE=({search:e},t)=>t.fetch(`https://api.jikan.moe/v4/anime?q=${encodeURIComponent(e)}`,lE).then(e=>e.json()).catch(e=>(console.error(`Jikan search failed`,e),{})).then(e=>e.data?lT(e.data,e=>hE(e,t),`Jikan search`):void 0),_E=({id:e},t)=>t.fetch(`https://api.jikan.moe/v4/anime/${e}/full`,lE).then(e=>e.json()).then(e=>e.data?hE(e.data,t):void 0),vE=(e=1,t)=>t.fetch(`https://api.jikan.moe/v4/seasons/now?page=${e}&sfw=true`,lE).then(e=>e.json()).catch(t=>(console.error(`Jikan season page ${e} failed`,t),{})),yE=({season:e,year:t},n,r)=>r.fetch(`https://api.jikan.moe/v4/seasons/${t}/${e}?page=${n}&sfw=true`,lE).then(e=>e.ok?e.json():{}).catch(r=>(console.error(`Jikan ${e} ${t} page ${n} failed`,r),{})),bE=(e,t)=>Promise.all(Array(Math.max(0,Math.min(2,(e?.last_visible_page??1)-1))).fill(void 0).map((e,n)=>t(n+2).then(({data:e})=>e??[]))),xE=e=>{let t=qT[e.typeId],{season:n,year:r}=Hw();return H({origin:`mal`,id:e.id,uri:`mal:${e.id}`,url:`https://myanimelist.net/anime/${e.id}`,categories:t===`MOVIE`?[`ANIME`,`MOVIE`]:[`ANIME`,`SERIES`],type:t===`TV`?FS.Tv:t===`MOVIE`?FS.Movie:t===`SPECIAL`?FS.Special:t===`OVA`?FS.Ova:t===`ONA`?FS.Ona:void 0,score:uE,titles:[...e.englishTitle?[{language:`en`,title:e.englishTitle,score:uE}]:[],{language:`jp-en`,title:e.title,score:uE}],covers:e.cover?[{language:`en`,url:e.cover,score:uE}]:[],genres:e.genres??[],descriptions:e.synopsis?[{language:`en`,description:e.synopsis,score:dE}]:[],shortDescriptions:e.synopsis?[{language:`en`,shortDescription:e.synopsis,score:dE}]:[],episodeCount:e.episodes,popularity:e.members,averageScore:nE(e.score,10),startDate:e.startDate,season:n,seasonYear:r})},SE=async e=>{try{let t=await(await e.fetch(`https://myanimelist.net/anime/season`)).text(),n=tE(t);if(!n.length)return console.error(`MyAnimeList season scrape parsed no entries from ${t.length} bytes`),[];let r=n.filter(e=>!KT(e));return n.some(e=>e.section)||console.error(`MyAnimeList season scrape found no section headings, so carried-over shows cannot be told apart`),r.map(xE)}catch(e){return console.error(`MyAnimeList season scrape failed`,e),[]}},CE=async e=>{let{data:t,pagination:n}=await vE(1,e);if(!t?.length)return SE(e);let r=await bE(n,t=>vE(t,e));return lT([...t,...r.flat()],t=>hE(t,e),`Jikan season`)},wE=async({season:e,year:t},n)=>{let{data:r,pagination:i}=await yE({season:e,year:t},1,n);if(!r?.length)return[];let a=await bE(i,r=>yE({season:e,year:t},r,n));return lT([...r,...a.flat()],e=>hE(e,n),`Jikan ${e} ${t}`)},TE={Query:{},Mutation:{},Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,`mal`);if(!r)return yield{media:null};yield{media:await _E({id:Number(r.id)},n)}}},mediaPage:{subscribe:async function*(e,{input:{search:t,status:n,season:r,seasonYear:i}},a){let o=r?Vw(r):void 0;if(o&&i){let e=Hw();return yield{mediaPage:{nodes:r===e.season&&i===e.year?await CE(a):await wE({season:o,year:i},a)}}}if(r||i){if(!t)return yield{mediaPage:{nodes:[]}}}else if(n===`RELEASING`)return yield{mediaPage:{nodes:await CE(a)}};if(t)return yield{mediaPage:{nodes:await gE({search:t},a)??[]}};yield{mediaPage:{nodes:[]}}}}}},EE=(e,t,n)=>{if(e?.year&&e.month&&e.day)return new Date(Date.UTC(e.year,e.month-1,e.day)).toUTCString();let r=(t?.edges??[]).map(e=>e?.node).filter(e=>!!e?.airingAt);if(r.length){let e=r.filter(e=>e.episode===1),t=n===`first`&&e.length?e[0]:r.reduce((e,t)=>(n===`first`?t.airingAt<e.airingAt:t.airingAt>e.airingAt)?t:e);return new Date(t.airingAt*1e3).toUTCString()}if(e?.year)return new Date(Date.UTC(e.year,(e.month??1)-1,e.day??1)).toUTCString()},DE=(e,t=new Date)=>{let n=t.getTime()/1e3,r=(e?.edges??[]).map(e=>e?.node).filter(e=>typeof e?.airingAt==`number`&&typeof e.episode==`number`&&e.airingAt>n);if(!r.length)return;let i=r.reduce((e,t)=>t.airingAt<e.airingAt?t:e);return{episodeNumber:i.episode,airingAt:new Date(i.airingAt*1e3).toUTCString()}};let OE=function(e){return e.Finished=`FINISHED`,e.Releasing=`RELEASING`,e.NotYetReleased=`NOT_YET_RELEASED`,e.Cancelled=`CANCELLED`,e.Hiatus=`HIATUS`,e}({});const kE=()=>{let e=new Uint8Array(40),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(e);else for(let t=0;t<e.length;t++)e[t]=Math.floor(Math.random()*256);let n=``;for(let t of e)n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`[t%62];return n},AE=e=>e.match(/al_token\s*=\s*"([A-Za-z0-9]{20,})"/)?.[1],jE=(e,t)=>e===403&&!!t?.errors?.some(e=>/use graphql subdomain/i.test(e?.message??``)),ME=e=>{try{return JSON.parse(e)}catch{return}},NE=e=>{let t,n,r=async()=>{let t=kE(),n=`https://anilist.co/search/anime/this-season?_=${t.slice(0,8)}`;try{let r=await e(n,{headers:{"user-agent":`Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36`,accept:`text/html,application/xhtml+xml`,cookie:`laravel_session=${t}`}}),i=await r.text(),a=AE(i);if(!a){console.error(`AniList frontend: no token in ${i.length} bytes of the page (HTTP ${r.status})`+(i.includes(`csrf_token()`)?`, the PHP template came back un-rendered`:``));return}return{token:a,session:t}}catch(e){console.error(`AniList frontend: could not reach the token page`,e);return}},i=async e=>(e&&(t=void 0),t||(n??=r().finally(()=>{n=void 0}),t=await n,t));return{query:async t=>{for(let n=0;n<2;n++){let r=await i(n>0);if(!r)return;let a;try{a=await e(`https://anilist.co/graphql`,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json`,"x-csrf-token":r.token,cookie:`laravel_session=${r.session}`},body:JSON.stringify(t)})}catch(e){console.error(`AniList frontend: request failed`,e);return}let o=ME(await a.text());if(jE(a.status,o)){if(n===0)continue;console.error(`AniList frontend: the gate refused a freshly acquired pair`);return}if(o?.errors?.length){let e=o.errors.map(e=>e.message).filter(Boolean).join(`; `);console.error(`AniList frontend request failed (HTTP ${a.status}): ${e||`no message`}`)}if(o?.data==null){o?.errors?.length||console.error(`AniList frontend returned no data (HTTP ${a.status})`);return}return o.data}},currentPair:()=>t}};var PE=c({categories:()=>LE,icon:()=>FE,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>RE,official:()=>!0,origin:()=>zE,originUrl:()=>IE,resolvers:()=>pD,supportedUris:()=>BE});const FE=`https://anilist.co/img/icons/favicon-32x32.png`,IE=`https://anilist.co`,LE=[`ANIME`,`SERIES`,`MOVIE`],RE=`Anilist`,zE=`anilist`,BE=[`anilist`],VE=`
959
+ id
960
+ idMal
961
+ title {
962
+ romaji
963
+ native
964
+ english
965
+ }
966
+ startDate {
967
+ year
968
+ month
969
+ day
970
+ }
971
+ endDate {
972
+ year
973
+ month
974
+ day
975
+ }
976
+ season
977
+ seasonYear
978
+ status
979
+ format
980
+ type
981
+ genres
982
+ tags {
983
+ name
984
+ isMediaSpoiler
985
+ isGeneralSpoiler
986
+ }
987
+ synonyms
988
+ duration
989
+ popularity
990
+ episodes
991
+ source(version: 2)
992
+ averageScore
993
+ siteUrl
994
+ description
995
+ bannerImage
996
+ coverImage {
997
+ medium
998
+ large
999
+ extraLarge
1000
+ color
1001
+ }
1002
+ trailer {
1003
+ id
1004
+ site
1005
+ thumbnail
1006
+ }
1007
+ externalLinks {
1008
+ site
1009
+ siteId
1010
+ url
1011
+ }
1012
+ airingSchedule {
1013
+ edges {
1014
+ node {
1015
+ airingAt
1016
+ episode
1017
+ id
1018
+ media {
1019
+ id
1020
+ idMal
1021
+ }
1022
+ mediaId
1023
+ timeUntilAiring
1024
+ }
1025
+ }
1026
+ }
1027
+ `,HE=`
1028
+ query (
1029
+ $search: String
1030
+ $season: MediaSeason
1031
+ $seasonYear: Int
1032
+ $format_in: [MediaFormat]
1033
+ $status: MediaStatus
1034
+ $genre_in: [String]
1035
+ $tag_in: [String]
1036
+ $sort: [MediaSort]
1037
+ $page: Int
1038
+ ) {
1039
+ Page(page: $page) {
1040
+ pageInfo {
1041
+ lastPage
1042
+ hasNextPage
1043
+ total
1044
+ }
1045
+ media(
1046
+ type: ANIME
1047
+ search: $search
1048
+ season: $season
1049
+ seasonYear: $seasonYear
1050
+ format_in: $format_in
1051
+ status: $status
1052
+ genre_in: $genre_in
1053
+ tag_in: $tag_in
1054
+ sort: $sort
1055
+ ) {
1056
+ ${VE.split(`
1057
+ `).join(`
1058
+ `)}
1059
+ }
1060
+ }
1061
+ }
1062
+ `,UE=`
1063
+ id
1064
+ idMal
1065
+ type
1066
+ format
1067
+ status
1068
+ episodes
1069
+ siteUrl
1070
+ title {
1071
+ romaji
1072
+ english
1073
+ native
1074
+ }
1075
+ coverImage {
1076
+ medium
1077
+ large
1078
+ color
1079
+ }
1080
+ startDate {
1081
+ year
1082
+ month
1083
+ day
1084
+ }
1085
+ `,WE=`
1086
+ query GetMedia ($id: Int, $idMal: Int, $type: MediaType) {
1087
+ Media(idMal: $idMal, id: $id, type: $type) {
1088
+ ${VE.split(`
1089
+ `).join(`
1090
+ `)}
1091
+ relations {
1092
+ edges {
1093
+ relationType(version: 2)
1094
+ node {
1095
+ ${UE.split(`
1096
+ `).join(`
1097
+ `)}
1098
+ relations {
1099
+ edges {
1100
+ relationType(version: 2)
1101
+ node {
1102
+ ${UE.split(`
1103
+ `).join(`
1104
+ `)}
1105
+ }
1106
+ }
1107
+ }
1108
+ }
1109
+ }
1110
+ }
1111
+ }
1112
+ }
1113
+ `,GE=.8,KE=[{siteId:5,mapper:async(e,t,n,r)=>{let i=e.url?.match(/https:\/\/www\.crunchyroll\.com\/series\/(\w+)/)?.[1];if(!i)return;let a=await r.similarMedia(`cr`,{showId:i,startDate:t.startDate,titles:t.titles,episodeCount:t.episodeCount,context:n??void 0});return a&&H({origin:a.origin,id:a.id,url:a.url,scope:a.scope})}}];let qE=0,JE;const YE=NE((e,t)=>{if(!JE)throw Error(`AniList frontend: queried before any request context bound a fetch`);return JE(e,t)}),XE=async({query:e,variables:t},n)=>{let r=await n.fetch(`https://graphql.anilist.co/`,{method:`POST`,spread:!0,headers:{"content-type":`application/json`},body:JSON.stringify({query:e,variables:t})}),i=await r.json().catch(()=>void 0);if(i?.errors?.length){let e=i.errors.map(e=>e.message).filter(Boolean).join(`; `);console.error(`AniList request failed (HTTP ${r.status}): ${e||`no message`}`)}if(i?.data==null){i?.errors?.length||console.error(`AniList returned no data (HTTP ${r.status})`);return}return i.data},ZE=async(e,t)=>{if(JE=t.fetch,Date.now()>=qE){let n=await XE(e,t).catch(()=>void 0);if(n!=null)return n;qE=Date.now()+3e5}return YE.query(e)},QE=async({id:e,idMal:t},n,r)=>{let i=await ZE({query:WE,variables:{id:e,idMal:t,type:`ANIME`}},n);if(!i?.Media)return;let a={startDate:EE(i.Media.startDate,i.Media.airingSchedule,`first`),titles:[i.Media.title?.english,i.Media.title?.romaji,i.Media.title?.native].filter(e=>!!e),episodeCount:i.Media.episodes??void 0},o=i.Media.externalLinks?.filter(e=>!!e).filter(e=>tD(e))??[],s=(await Promise.all(o.map(async e=>{let t=KE.find(t=>t.siteId===e.siteId);if(t)try{return await t.mapper(e,a,r,n)}catch(t){console.error(`anilist mapper for siteId ${e.siteId} failed:`,t);return}}))).filter(e=>!!e);return uD(i.Media,s)},$E=(e,t,n)=>ZE({query:HE,variables:{...e,page:t}},n),eD=async(e,t)=>{let n=await $E(e,1,t),r=n?.Page?.pageInfo?.lastPage;return lT([...n?.Page?.media??[],...!e.search&&r?(await Promise.all(Array(Math.min(2,r-1)).fill(void 0).map((n,r)=>$E(e,r+2,t).then(e=>e?.Page?.media??[])))).flat():[]],e=>uD(e),`AniList browse`)},tD=e=>!!e?.siteId,nD=e=>!!e?.name&&!e?.isMediaSpoiler&&!e?.isGeneralSpoiler,rD=e=>zw.find(t=>t===e),iD=new Set([`ADAPTATION`,`PREQUEL`,`SEQUEL`,`PARENT`,`SIDE_STORY`,`CHARACTER`,`SUMMARY`,`ALTERNATIVE`,`SPIN_OFF`,`SOURCE`,`COMPILATION`,`CONTAINS`,`OTHER`]),aD=e=>(e.relations?.edges??[]).flatMap(e=>{let t=e?.node;if(!t?.id)return[];let n=String(e?.relationType??``);return[{relation:iD.has(n)?n:`OTHER`,format:t.format??void 0,node:H({origin:zE,id:t.id.toString(),url:t.siteUrl??void 0,score:GE,episodeCount:t.episodes??void 0,startDate:cD(t.startDate),titles:[...t.title?.english?[{language:`en`,title:t.title.english,score:GE}]:[],...t.title?.romaji?[{language:`jp-en`,title:t.title.romaji,score:GE}]:[],...t.title?.native?[{language:`jp`,title:t.title.native,score:GE}]:[]],covers:t.coverImage?.large?[{language:`jp`,url:t.coverImage.large,color:t.coverImage.color??void 0,score:GE}]:[],status:t.status===OE.NotYetReleased?PS.NotYetReleased:t.status===OE.Releasing?PS.Releasing:t.status===OE.Finished?PS.Finished:void 0})}]}),oD=new Set([`SEQUEL`,`PREQUEL`,`SIDE_STORY`,`SPIN_OFF`,`ALTERNATIVE`,`PARENT`,`SOURCE`,`ADAPTATION`,`SUMMARY`,`COMPILATION`,`CONTAINS`]),sD=e=>{let t=e=>`${zE}:${e}`,n=new Map,r=new Map,i=e=>(e.relations?.edges??[]).filter(Boolean),a=e=>{let r=t(e.id);return n.has(r)||n.set(r,lD(e)),r};a(e);let o=[{uri:t(e.id),node:e}];for(let e=0;e<2&&o.length;e++){let e=[];for(let t of o)for(let n of i(t.node)){let i=n.node,o=String(n.relationType??``);if(!i?.id||!oD.has(o))continue;let s=a(i),c=`${t.uri}\u0000${s}\u0000${o}`;r.has(c)||r.set(c,{from:t.uri,to:s,relation:o}),e.push({uri:s,node:i})}o=e}if(!(n.size<2))return{nodes:[...n.values()],edges:[...r.values()]}},cD=e=>{if(!e?.year)return;let t=e=>String(e??1).padStart(2,`0`);return`${e.year}-${t(e.month)}-${t(e.day)}`},lD=e=>({uri:`${zE}:${e.id}`,format:e.format??void 0,episodeCount:e.episodes??void 0,startDate:cD(e.startDate),status:e.status===OE.NotYetReleased?PS.NotYetReleased:e.status===OE.Releasing?PS.Releasing:e.status===OE.Finished?PS.Finished:void 0,titles:[...e.title?.english?[{language:`en`,title:e.title.english,score:GE}]:[],...e.title?.romaji?[{language:`jp-en`,title:e.title.romaji,score:GE}]:[]],covers:e.coverImage?.large?[{language:`jp`,url:e.coverImage.large,color:e.coverImage.color??void 0,score:GE}]:[]}),uD=(e,t=[])=>{let n=e.idMal?H({_id:crypto.randomUUID(),uri:`mal:${e.idMal}`,origin:`mal`,id:e.idMal.toString(),url:`https://myanimelist.net/anime/${e.idMal}`}):void 0,r=EE(e.startDate,e.airingSchedule,`first`),i=EE(e.endDate,e.airingSchedule,`last`);return H({_id:crypto.randomUUID(),uri:`${zE}:${e.id}`,origin:zE,id:e.id.toString(),url:e.siteUrl,categories:e.format===`MOVIE`?[`ANIME`,`MOVIE`]:[`ANIME`,`SERIES`],genres:(e.genres??[]).filter(e=>!!e),tags:(e.tags??[]).filter(nD).map(e=>e.name),season:rD(e.season),seasonYear:e.seasonYear,type:e.format===`TV`?FS.Tv:e.format===`TV_SHORT`?FS.TvShort:e.format===`MOVIE`?FS.Movie:e.format===`SPECIAL`?FS.Special:e.format===`OVA`?FS.Ova:e.format===`ONA`?FS.Ona:void 0,handles:[...t,...n?[n]:[]],relations:aD(e),franchise:sD(e),score:GE,averageScore:nE(e.averageScore,100),nextAiringEpisode:DE(e.airingSchedule),descriptions:e.description?[{language:`en`,description:e.description,score:GE}]:[],shortDescriptions:e.description?[{language:`en`,shortDescription:e.description,score:GE}]:[],titles:[...e.title?.english?[{language:`en`,title:e.title.english,score:GE}]:[],...e.title?.romaji?[{language:`jp-en`,title:e.title.romaji,score:GE}]:[],...e.title?.native?[{language:`jp`,title:e.title.native,score:GE}]:[]],covers:[...e.coverImage?.extraLarge?[{language:`jp`,url:e.coverImage.extraLarge,color:e.coverImage.color??void 0,score:GE}]:[]],episodeCount:e.episodes,popularity:e.popularity,status:e.status===OE.NotYetReleased?PS.NotYetReleased:e.status===OE.Releasing?PS.Releasing:e.status===OE.Finished?PS.Finished:e.status===OE.Cancelled?PS.Cancelled:e.status===OE.Hiatus?PS.Hiatus:void 0,startDate:r,endDate:i,trailers:e.trailer?.site===`youtube`&&e.trailer.id?[{uri:`yt:${e.trailer.id}`,language:`en`,origin:`yt`,id:e.trailer.id.toString(),url:`https://www.youtube.com/watch?v=${e.trailer.id}`,thumbnail:e.trailer.thumbnail}]:[]})},dD=[`TV`,`TV_SHORT`,`MOVIE`,`SPECIAL`,`OVA`,`ONA`],fD=e=>{let t=e.search||void 0;if(!(e.status||t||e.season||e.seasonYear||e.formats?.length||e.genres?.length||e.tags?.length))return;let n=(e.formats??[]).filter(e=>dD.includes(e));return{search:t,season:e.season??void 0,seasonYear:e.seasonYear??void 0,format_in:n.length?n:void 0,status:e.status??void 0,genre_in:e.genres?.length?e.genres:void 0,tag_in:e.tags?.length?e.tags:void 0,sort:t?[`SEARCH_MATCH`]:[`POPULARITY_DESC`]}},pD={Subscription:{media:{subscribe:async function*(e,{input:{uri:t,context:n}},r){if(!t||!(HS(t)||qS(t)))return yield{media:null};let i=LS(t,zE);if(!i)return yield{media:null};yield{media:await QE({id:Number(i.id)},r,n)}}},mediaPage:{subscribe:async function*(e,{input:t},n){let r=fD(t);r&&(yield{mediaPage:{nodes:await eD(r,n)}})}}}};var mD=c({categories:()=>_D,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>vD,official:()=>!1,origin:()=>gD,originUrl:()=>hD,resolvers:()=>TD,supportedUris:()=>yD});const hD=`https://api.ani.zip/`,gD=`anizip`,_D=[`ANIME`,`SERIES`],vD=`AniZip`,yD=[`anidb`,`mal`],bD=.9,xD=(e,t)=>{let n=e.mappings.anidb_id.toString(),r=`${gD}:${n}`,i=[e.mappings.mal_id?H({origin:`mal`,id:String(e.mappings.mal_id),url:`https://myanimelist.net/anime/${e.mappings.mal_id}`}):void 0,e.mappings.anilist_id?H({origin:`anilist`,id:String(e.mappings.anilist_id),url:`https://anilist.co/anime/${e.mappings.anilist_id}`}):void 0].filter(e=>!!e);return H({origin:gD,id:n,categories:[`ANIME`,`SERIES`],url:`https://api.ani.zip/mappings?anidb_id=${n}`,handles:i,titles:[...e.titles.en?[{language:`en`,title:e.titles.en,score:bD}]:[],...e.titles.ja?[{language:`ja`,title:e.titles.ja,score:bD}]:[]],covers:e.images?.filter(e=>e.coverType===`Poster`).map(e=>({url:e.url,score:bD}))??[],banners:e.images?.filter(e=>e.coverType===`Banner`).map(e=>({url:e.url,score:bD}))??[],episodeCount:e.episodeCount,episodes:Object.entries(e.episodes).map(([e,t])=>{let i=`${n}-${e}`;return oT({origin:gD,id:i,mediaUri:r,url:`https://api.ani.zip/mappings?anidb_id=${n}`,score:bD,titles:[...t.title.en?[{language:`en`,title:t.title.en,score:bD}]:[],...t.title.ja?[{language:`ja`,title:t.title.ja,score:bD}]:[]],descriptions:t.overview?[{language:`en`,description:t.overview,score:bD}]:[],shortDescriptions:t.summary?[{language:`en`,shortDescription:t.summary,score:bD}]:t.overview?[{language:`en`,shortDescription:t.overview,score:bD}]:[],thumbnails:t.image?[{url:t.image,score:bD}]:[],seasonNumber:t.seasonNumber,episodeNumber:/^\d+$/.test(e)?Number(e):t.episodeNumber,absoluteEpisodeNumber:t.absoluteEpisodeNumber,runtime:t.runtime??t.length,releaseDate:t.airDateUtc??t.airdate})})})},SD=(e,t,n)=>n.fetch(`https://api.ani.zip/mappings?${e}_id=${t}&specials=1`).then(e=>e.json()),CD=(e,t,n)=>SD(e,t,n).then(e=>e?.mappings?.anidb_id==null?null:xD(e,n)),wD=(e,t)=>CD(`mal`,e,t),TD={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!qS(t))return yield{media:null};let r=ZS(t)?.handleUrisValues.find(e=>e.origin===`mal`);if(!r)return yield{media:null};yield{media:await wD(r.id,n)}}}}},ED=e=>[...new Set([e,...BT(e)])].slice(0,4),DD=async(e,t,n)=>(await Promise.all(t.map(async t=>{let r=n(t);return{candidate:t,score:r?await kT(e,r):0}}))).filter(e=>e.score>=.9).sort((e,t)=>t.score-e.score).slice(0,3),OD=e=>{if(e==null||e===``)return;let t=new Date(e);return isNaN(t.getTime())?void 0:t},kD=(e,t)=>{let n=OD(e)?.getUTCFullYear();return n===void 0?!1:t.some(e=>e===n)},AD=(e,t,n)=>{let r=OD(e);if(!r)return;let i;for(let e of t){let t=OD(n(e));if(!t)continue;let a=Math.abs(t.getTime()-r.getTime());(!i||a<i.diff)&&(i={season:e,diff:a})}return i},jD=async(e,t,n,r,i)=>{if(!e.startDate)return;let a=await DD(e.titles,t,n),o;for(let{candidate:t}of a){let n=AD(e.startDate,await r(t),i);!n||n.diff>3888e6||(!o||n.diff<o.diff)&&(o={candidate:t,season:n.season,diff:n.diff})}return o},MD=e=>{if(e==null||e===``)return;let t=typeof e==`number`?e:Date.parse(e);return Number.isNaN(t)?void 0:t},ND=e=>{let t=MD(e);return t===void 0?void 0:new Date(t).getUTCFullYear()},PD=({startDate:e,titles:t,episodeCount:n,episodeTitles:r})=>!!(e&&!Number.isNaN(Date.parse(e)))||!!t?.length||n!=null||!!r?.length,FD=/\b(?:part|cour)\s*(?:\d{1,3}|[ivx]{1,4}|one|two|three|four|five|six|seven|eight|nine|ten)\b/i,ID=/\b(?:\d{1,3}(?:st|nd|rd|th)|first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|final|last)\s+(?:part|cour|half)\b/i,LD=e=>FD.test(e)||ID.test(e),RD=e=>new Set((e??[]).map(Yw).filter(e=>e!=null)),zD=/\b(?:part|cour|half)\b/i,BD=e=>new Set((e??[]).map(e=>{let t=e.search(zD);return t<0?e:e.slice(0,t)}).map(Yw).filter(e=>e!=null)),VD=/^(?:episode|ep|e|part|chapter|第)?\s*\d+\s*(?:話|集|화)?$/,HD=/\p{L}/u,UD=e=>{let t=mT(e);return!HD.test(t)||VD.test(t)},WD=e=>e.find(e=>eT(e))??e.find(e=>!!e),GD=(e,t,n)=>n.origin===e&&n.scope!==`CONTAINER`&&n.id!==t,KD=e=>e.year??ND(e.premiere),qD=e=>e.episodeCount||void 0,JD=(e,t)=>{let n=qD(t);return n!=null&&e.episodeCount!=null&&n>e.episodeCount},YD=(e,t)=>{let n=KD(t),r=ND(e.startDate);return n!=null&&r!=null&&n!==r},XD=e=>(e??[]).filter(e=>!UD(e)),ZD=(e,t)=>{let n=e.titles??[],r=n.some(LD),i=RD(n),a=ND(e.startDate),o=eT(e.startDate)?MD(e.startDate):void 0;if(o!==void 0&&t.some(e=>MD(e.premiere)!==void 0)){let n=t.filter(e=>{let t=MD(e.premiere);return t!==void 0&&Math.abs(t-o)<=3888e6});return n.length!==1||JD(e,n[0])?void 0:{season:n[0].season,rule:`date`}}let s=t,c=new Set(XD(e.episodeTitles).map(mT));if(c.size>=3){let n=t.map(e=>({candidate:e,theirs:XD(e.episodeTitles)})).filter(({theirs:e})=>e.length>=3);if(n.length){let r=n.filter(({theirs:e})=>{let t=e.filter(e=>c.has(mT(e))).length;return t>=3&&t/e.length>=.6});if(r.length>1)return;if(r.length===1){let t=r[0].candidate;return JD(e,t)||YD(e,t)?void 0:{season:t.season,rule:`episode-titles`}}let i=new Set(n.map(({candidate:e})=>e));if(s=t.filter(e=>!i.has(e)),!s.length)return}}if(i.size>1)return;if(i.size===1&&!r&&e.episodeCount!=null){let[t]=i,n=s.filter(e=>e.seasonNumber===t);if(n.length>1)return;if(n.length===1&&qD(n[0])!=null){let t=n[0];return JD(e,t)||YD(e,t)?void 0:{season:t.season,rule:`ordinal`}}}let l=i.size===0&&!r&&e.episodeCount!=null;if(l&&a!=null&&t.some(e=>KD(e)!=null)){let t=s.filter(e=>KD(e)===a);if(t.length===1){let n=t[0];return qD(n)==null||JD(e,n)?void 0:{season:n.season,rule:`year`}}}if(l){let n=t.filter(e=>e.seasonNumber!=null),r=t.length===1?t[0]:n.length?n.reduce((e,t)=>t.seasonNumber<e.seasonNumber?t:e):void 0;if(!r||!s.includes(r)||JD(e,r)||YD(e,r))return;let i=qD(r);return(t.length===1?i!=null&&i<=e.episodeCount:i===e.episodeCount)?{season:r.season,rule:`first`}:void 0}},QD=(e,t)=>{if(ZD(e,t))return;let n=e.episodeCount;if(n==null||n<=0)return;let r=e.titles??[],i=RD(r);if(i.size>1)return;let a=i.size===1&&!r.some(LD)?[...i][0]:void 0,o=e=>a===void 0||e.seasonNumber==null||e.seasonNumber<=a,s=t.filter(e=>{let t=qD(e);return t==null||t<=n?!1:o(e)});if(!s.length)return;let c=(e,t)=>({season:e.season,rule:t,theirs:qD(e),ours:n}),l=e=>{let t=qD(e);return n/t<.6&&n*4>=t},u=s,d=new Set(XD(e.episodeTitles).map(mT));if(d.size>=3){let e=s.map(e=>({candidate:e,theirs:XD(e.episodeTitles)})).filter(({theirs:e})=>e.length>=3),t=e.filter(({candidate:e,theirs:t})=>{let r=t.filter(e=>d.has(mT(e))).length;return r>=3&&r/n>=.6&&r/qD(e)<.6});if(t.length>1)return;if(t.length===1)return c(t[0].candidate,`episode-titles`);let r=new Set(e.map(({candidate:e})=>e));u=s.filter(e=>!r.has(e))}let f=BD(r);if(f.size===1){let[e]=f,n=t.filter(t=>t.seasonNumber===e);if(n.length>1)return;if(n.length===1){let e=n[0];return!s.includes(e)||!l(e)?void 0:c(e,`ordinal`)}}if(t.some(e=>qD(e)==null&&o(e)))return;let p=ND(e.startDate);if(p==null)return;let m=u.filter(e=>KD(e)===p&&l(e));return m.length===1?c(m[0],`year`):void 0},$D=e=>(e.episodeCount??0)>0,eO=(e,t)=>e-t,tO=e=>{let t=MD(e);return t===void 0?`-`:new Date(t).toISOString().slice(0,10)},nO=e=>{let t=e.titles??[],n=[...RD(t)].sort(eO);return`{day:${tO(e.startDate)}, count:${e.episodeCount??`-`}, ordinals:${n.length?n.join(`,`):`-`}, parts:${t.some(LD)?`yes`:`no`}, titles:${t.length}, episodeTitles:${(e.episodeTitles??[]).length}}`},rO=e=>(e??``).replace(/[^\x21-\x7e]/g,`_`).slice(0,128)||`-`,iO=.9,aO=async(e,t)=>{let n=e.filter(e=>e.trim()),r=t.filter(e=>e.trim());if(!n.length||!r.length)return{ok:!1,score:0};let i=await Promise.all(r.map(e=>kT(n,e))),a=Math.max(...i);return{ok:a>=iO,score:a}},oO=(e,t,n)=>{let r=tO(n.startDate),i=n.titles??[],a=[...RD(i)].sort(eO).join(`,`),o=i.some(LD)?`p`:``,s=[...new Set(XD(n.episodeTitles).map(mT))].sort().join(``);return[e,t,r,n.episodeCount??`-`,a,o,s].join(`\0`)};var sO=c({categories:()=>dO,cdnImageUrl:()=>jO,crunchyrollId:()=>kO,getMedia:()=>zO,icon:()=>lO,isApiOnly:()=>!1,metadataOnly:()=>!1,name:()=>fO,official:()=>!0,origin:()=>`cr`,originUrl:()=>uO,resetCrunchyrollCaches:()=>UO,resolveEpisodeToSeriesId:()=>EO,resolvers:()=>JO,supportedUris:()=>pO});const cO=.5,lO=`https://static.crunchyroll.com/cxweb/assets/img/favicons/favicon-96x96.png`,uO=`https://www.crunchyroll.com`,dO=[`ANIME`,`SERIES`],fO=`Crunchyroll`,pO=[`cr`];let mO,hO;const gO=async e=>mO&&Date.now()-mO.timestamp<mO.expires_in*1e3?mO:hO||(hO=(async()=>{let t=await e.fetch(`https://www.crunchyroll.com/auth/v1/token`,{headers:{accept:`application/json, text/plain, */*`,authorization:`Basic ${btoa(`cr_web:`)}`,"content-type":`application/x-www-form-urlencoded`},body:`grant_type=client_id`,method:`POST`,mode:`cors`,credentials:`include`}).then(e=>e.json());if(!t.access_token)throw Error(`Crunchyroll token fetch failed: ${JSON.stringify(t)}`);return mO={timestamp:Date.now(),access_token:t.access_token,expires_in:t.expires_in}})().finally(()=>{hO=void 0}),hO),_O=new Map,vO=async(e,t)=>{let n=_O.get(e);if(n)return n;let r=gO(t).then(n=>t.fetch(e,{headers:{accept:`application/json, text/plain, */*`,authorization:`Bearer ${n.access_token}`},mode:`cors`,credentials:`include`}).then(e=>e.json()));_O.set(e,r);let i=()=>{_O.delete(e)};return r.then(i,i),r},yO=`https://www.crunchyroll.com/content/v2/cms`,bO=(e,t)=>{let n=e?.data;if(!Array.isArray(n))throw Error(`Crunchyroll answered ${t} with no data: ${JSON.stringify(e)?.slice(0,200)}`);return n},xO=(e,t)=>vO(e,t).then(t=>({data:bO(t,e)})),SO=(e,t)=>xO(`${yO}/series/${e}?preferred_audio_language=ja-JP&locale=en-US`,t),CO=(e,t)=>xO(`${yO}/series/${e}/seasons?force_locale=&preferred_audio_language=ja-JP&locale=en-US`,t),wO=(e,t)=>xO(`${yO}/seasons/${e}/episodes?preferred_audio_language=ja-JP&locale=en-US`,t),TO=(e,t)=>vO(`https://www.crunchyroll.com/content/v2/discover/search?q=${encodeURIComponent(e)}&n=50&type=series&locale=en-US`,t).then(e=>({data:e?.data??[]})),EO=async(e,t)=>{let n=(await vO(`${yO}/objects/${e}?ratings=true&locale=en-US`,t)).data?.[0]?.episode_metadata;return n?.series_id?{seriesId:n.series_id,seasonId:n.season_id}:void 0},DO=e=>e.replace(/JAJP$/,``),OO=e=>e.versions?.find(e=>e.audio_locale===`ja-JP`)?.guid??e.versions?.find(e=>e.original)?.guid??DO(e.id),kO=(e,t,n)=>[e,t&&DO(t),n].filter(Boolean).join(`-`),AO=/^https?:\/\/www\.crunchyroll\.com\/imgsrv\/display\/[^/]+\/(\d+)x\d+\/(.+)$/,jO=e=>{let t=e.match(AO);return t?`https://imgsrv.crunchyroll.com/cdn-cgi/image/fit=contain,format=auto,quality=85,width=${t[1]}/${t[2]}`:e},MO=e=>{let t=e?.at(-1)?.at(-1)?.source;return t&&jO(t)},NO=(e,t)=>e===t.id?`CONTAINER`:`RUN`,PO=(e,t,n,r,i)=>H({origin:`cr`,id:e,scope:NO(e,r),url:`https://www.crunchyroll.com/series/${r.id}/${r.slug_title}`,score:cO,categories:[`ANIME`,`SERIES`],titles:[{language:`en`,title:t,score:cO}],...uT(n,cO),covers:dT(MO(r.images?.poster_tall),cO),banners:dT(MO(r.images?.poster_wide),cO),startDate:e===r.id&&r.series_metadata?.series_launch_year?`${r.series_metadata.series_launch_year}-01-01`:void 0,episodeCount:i}),FO=(e,t)=>oT({origin:`cr`,id:kO(e.series_id,e.season_id,e.id),mediaUri:t,url:`https://www.crunchyroll.com/watch/${e.id}`,score:cO,titles:[{language:`en`,title:e.title,score:cO}],...uT(e.description,cO),thumbnails:dT(MO(e.images?.thumbnail),cO),seasonNumber:e.season_number,episodeNumber:e.episode_number,absoluteEpisodeNumber:e.sequence_number,releaseDate:e.episode_air_date?new Date(e.episode_air_date).toISOString():void 0}),IO=e=>{let t=new Map;for(let n of e)n.episodeNumber!=null&&t.set(n.episodeNumber,n);return e.filter(e=>e.episodeNumber==null||t.get(e.episodeNumber)===e)},LO=async(e,t,n)=>{let{data:r}=await wO(e,n);return IO(r.map(e=>FO(e,t)))},RO=(e,t)=>e.find(e=>DO(e.id)===t||OO(e)===t),zO=async(e,t)=>{let[n,r]=e.split(`-`);if(!n)return;let[i,a]=await Promise.all([SO(n,t),CO(n,t)]),o=i.data[0];if(!o)return;let s=a.data,c=r?RO(s,r):s.length===1?s[0]:void 0;if(r&&!c)return;let l=c&&!Jw(c.title)?c.title:void 0,u=c?PO(kO(n,OO(c)),l??o.title,c.description||o.description,o):PO(o.id,o.title,o.description,o);if(c&&(u.episodes=await LO(OO(c),u.uri,t),u.episodeCount=u.episodes.length,!u.startDate)){let e=u.episodes.map(e=>e.releaseDate).filter(e=>typeof e==`string`&&!Number.isNaN(Date.parse(e))).sort();e.length&&(u.startDate=e[0])}return u},BO=async(e,t)=>{let{data:n}=await CO(e,t);if(!n.length)return{seasons:n,candidates:[]};let r=n.filter(e=>e.audio_locale===`ja-JP`),i=r.length>0?r:n;return{seasons:n,candidates:await Promise.all(i.map(async e=>{let n=OO(e),{data:r}=await wO(n,t);return{season:{resolvedId:n},seasonNumber:r[0]?.season_number,episodeCount:new Set(r.filter(e=>e.episode_number!=null).map(e=>e.episode_number)).size,premiere:r[0]?.episode_air_date||void 0,episodeTitles:r.map(e=>e.title),airDates:r.map(e=>e.episode_air_date).filter(e=>!!e)}}))}},VO=new Map,HO=(e,t)=>{let n=VO.get(e);if(n&&Date.now()-n.at<6e5)return n.promise;let r=BO(e,t);return VO.set(e,{at:Date.now(),promise:r}),r.catch(()=>{VO.get(e)?.promise===r&&VO.delete(e)}),r},UO=()=>{VO.clear()},WO=e=>{let t=e?Date.parse(e):NaN;return Number.isFinite(t)?Math.floor(t/864e5):void 0},GO=async(e,t,n,r)=>{let i=WO(t.startDate??void 0),a=t.episodeCount;if(i==null||a==null)return;let o=e.flatMap(({seriesId:e,candidates:t})=>t.filter(e=>(e.episodeCount??0)>a).filter(e=>{let t=(e.airDates??[]).map(WO).filter(e=>e!=null);return t.length>1&&i>=Math.min(...t)-1&&i<=Math.max(...t)+1}).map(t=>({seriesId:e,seasonId:t.season.resolvedId})));if(o.length!==1)return;let s=o[0],c=await zO(kO(s.seriesId,s.seasonId),r);if(!c?.episodes?.length)return;let l=ZS(n)?.handleUris?.[0];if(l)return{...c,handles:[],episodes:c.episodes.map(e=>({...e,mediaUri:l}))}},KO=async(e,t)=>{let n=await UT(e,t,e=>fT(e)&&e.startDate?e:void 0,3e4);if(!n?.startDate||isNaN(new Date(n.startDate).getTime()))return;let r=(n.titles??[]).map(e=>e.title).filter(Boolean),i=r[0];if(!i)return;let a=[...new Set([i,...BT(i)])].slice(0,4);for(let i of a){let{data:a}=await TO(i,t),o=a.find(e=>e.type===`series`)?.items??[];if(!o.length)continue;let s=(await Promise.all(o.map(async e=>({series:e,score:await kT(r,e.title)})))).filter(e=>e.score>=.9).sort((e,t)=>t.score-e.score).slice(0,3);if(!s.length)continue;let c={startDate:n.startDate,titles:r,episodeCount:n.episodeCount},l,u=[];for(let{series:e}of s){let{candidates:n}=await HO(e.id,t);u.push({seriesId:e.id,candidates:n});let r=ZD(c,n);if(r){l={seriesId:e.id,seasonId:r.season.resolvedId};break}}if(l){let n=await zO(kO(l.seriesId,l.seasonId),t);if(!n)continue;return n.handles=VT(e,`cr`),n}let d=await GO(u,c,e,t);if(d)return d}},qO=async(e,t)=>{let{candidates:n}=await HO(e.showId,t);if(!n.length)return;let r=ZD(e,n);if(r)return console.warn(`similarMedia: cr picked ${r.season.resolvedId} by ${r.rule} for ${e.showId}`),await zO(kO(e.showId,r.season.resolvedId),t)},JO={Subscription:{similarMedia:{subscribe:async function*(e,{input:t},n){if(!t?.showId)return yield{similarMedia:null};yield{similarMedia:await qO(t,n)??null}}},media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,`cr`);if(r)return yield{media:await zO(r.id,n)??null};if(!qS(t))return yield{media:null};yield{media:await KO(t,n)??null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:((await TO(t,n)).data.find(e=>e.type===`series`)?.items??[]).map(e=>PO(e.id,e.title,e.description,e,e.series_metadata?.episode_count))}}}}},Media:{episodes:async(e,t,n)=>e.origin===`cr`?e.episodes?.length?e.episodes:(await zO(e.id,n))?.episodes??[]:e.episodes??[]}},YO=`https://www.netflix.com/graphql`,XO={id:`217277fd-12a1-4816-a5b2-b9d7b9afd4ea`,version:102},ZO=e=>({videoId:e,opaqueImageFormat:`JPG`,transparentImageFormat:`PNG`,thumbnailVideoId:0,hasValidThumbnailVideoId:!1,useBakedInPlayThumbnail:!1,useFromWatchSupplements:!1,isModernizedSignup:!1}),QO={"persisted-query-stale":`ours: Netflix edited the query and this app's copy of its id is stale`,"http-status":`Netflix's: their endpoint refused the request`,"graphql-errors":`Netflix's: their endpoint rejected the operation`,"not-netflix":`neither: something between this browser and www.netflix.com answered instead`,unreadable:`Netflix's: their payload is no longer the shape this app parses`,unreachable:`ours: the request never arrived at Netflix`},$O=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,ek=e=>Array.isArray(e)?e:[],tk=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,nk=e=>typeof e==`string`&&e.length?e:void 0,rk=(...e)=>{for(let t of e){let e=t?.match(/\d+/);if(e)return Number(e[0])}},ik=e=>{let t=$O(e);if(!(!t||t.available===!1))return nk(t.url)},ak=e=>{let t=$O($O(e)?.node),n=tk(t?.videoId);if(!(!t||n===void 0))return{videoId:n,number:tk(t.number),title:nk(t.title)??``,synopsis:nk(t.shortSynopsis),runtimeSec:tk(t.runtimeSec),thumbnail:ik(t.merchStill300)}},ok=e=>{let t=$O($O(e)?.node),n=tk(t?.videoId);if(!t||n===void 0)return;let r=$O(t.episodes),i=nk(t.title)??``,a=ek(r?.edges).map(ak).filter(e=>!!e);return{videoId:n,number:rk(nk(t.numberLabelV2),nk(t.shortTitle),i),title:i,episodes:a,truncated:!!r&&sk(r,a.length)}},sk=(e,t)=>$O(e?.pageInfo)?.hasNextPage!==!1||t>=10,ck=async e=>{let t;try{t=await e.text()}catch(e){return{ok:!1,failure:`unreachable`,message:`the answer body could not be read: ${String(e)}`}}let n;try{n=JSON.parse(t)}catch{return{ok:!1,failure:`not-netflix`,message:`a 200 that is not JSON answered for ${YO}: ${lk(t)}`}}let r=$O(n);return!r||!(`data`in r)&&!(`errors`in r)?{ok:!1,failure:`not-netflix`,message:`a 200 that is not a GraphQL answer came back for ${YO}: ${lk(t)}`}:{ok:!0,body:r}},lk=e=>`${e.slice(0,160).replace(/\s+/g,` `)}${e.length>160?`...`:``}`,uk=e=>{let t=ek(e.errors).map($O),n=t.some(e=>{let t=$O(e?.extensions);return t?.code===`PERSISTED_QUERY_NOT_FOUND`||t?.errorType===`PERSISTED_QUERY_NOT_FOUND`||e?.message===`PersistedQueryNotFound`||(nk($O(t?.debugInfo)?.exception)??``).includes(`PersistedQuery`)}),r=t.filter(e=>{let t=$O(e?.extensions);return!(ek(e?.path).length>0&&(t?.errorType===`UNAUTHENTICATED`||t?.code===`UNAUTHENTICATED`))});return{stale:n,fatal:r.length>0,message:(r.length?r:t).map(e=>nk(e?.message)??`unnamed error`).join(`; `)}},dk=async(e,t)=>{let n=Number(e);if(!Number.isFinite(n))return{ok:!1,failure:`unreadable`,message:`not a Netflix video id: ${e}`};let r;try{r=await t.fetch(YO,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`,"x-netflix.context.locales":`en`},body:JSON.stringify({operationName:`LodpTitleAndPlansPageQuery`,variables:ZO(n),extensions:{persistedQuery:XO}}),mode:`cors`,credentials:`omit`})}catch(e){return{ok:!1,failure:`unreachable`,message:String(e)}}if(r.ok===!1)return{ok:!1,failure:`http-status`,message:`Netflix answered ${r.status}`};let i=await ck(r);if(!i.ok)return i;let a=i.body,{stale:o,fatal:s,message:c}=uk(a);if(o)return{ok:!1,failure:`persisted-query-stale`,message:`${c}. Re-read NETFLIX_PERSISTED_QUERY from Netflix's page bundle`};if(s)return{ok:!1,failure:`graphql-errors`,message:c};let l=$O(a.data);if(!l)return{ok:!1,failure:`unreadable`,message:`Netflix answered no data`};if(!Array.isArray(l.videos))return{ok:!1,failure:`unreadable`,message:`Netflix answered no videos list`};let u=$O(l.videos[0]);if(!u)return{ok:!0,title:void 0};let d=tk(u.videoId);if(d===void 0)return{ok:!1,failure:`unreadable`,message:`Netflix answered a video with no videoId`};let f=$O(u.seasons),p=ek(f?.edges).map(ok).filter(e=>!!e);return{ok:!0,title:{videoId:d,title:nk(u.title)??``,synopsis:nk(u.shortSynopsis),year:tk(u.latestYear),seasons:p,seasonsTruncated:!!f&&sk(f,p.length)}}},fk={id:`4cf0a279-dd32-454d-9758-486359c0d48b`,version:102},pk=(e,t)=>({seasonId:e,count:40,opaqueImageFormat:`WEBP`,artworkContext:{},...t===void 0?{}:{cursor:t}}),mk=e=>{let t=$O(e);if(!(!t||t.available===!1)&&(nk(t.key)??``).startsWith(`MERCH_STILL`))return nk(t.url)},hk=e=>{let t=$O($O(e)?.node),n=tk(t?.videoId);if(!(!t||n===void 0))return{videoId:n,number:tk(t.number),title:nk(t.title)??``,synopsis:nk($O(t.contextualSynopsis)?.text),runtimeSec:tk(t.runtimeSec)??tk(t.displayRuntimeSec),thumbnail:mk(t.artwork)}},gk={"no-such-season":`Netflix's, for the country this request came from: they list no season under that id`,"not-in-this-catalogue":`Netflix's, for the country this request came from: they say the show is not available in it`,"no-episodes-listed":`Netflix's: the season is in this country's catalogue and lists no episodes`},_k=async(e,t,n)=>{let r;try{r=await n.fetch(YO,{method:`POST`,headers:{accept:`application/json`,"content-type":`application/json`,"x-netflix.context.locales":`en`},body:JSON.stringify({operationName:`PreviewModalEpisodeSelectorSeasonEpisodes`,variables:pk(e,t),extensions:{persistedQuery:fk}}),mode:`cors`,credentials:`omit`})}catch(e){return{ok:!1,failure:`unreachable`,message:String(e)}}if(r.ok===!1)return{ok:!1,failure:`http-status`,message:`Netflix answered ${r.status}`};let i=await ck(r);if(!i.ok)return i;let a=i.body,{stale:o,fatal:s,message:c}=uk(a);if(o)return{ok:!1,failure:`persisted-query-stale`,message:`${c}. Re-read NETFLIX_SEASON_QUERY from Netflix's page bundle`};if(s)return{ok:!1,failure:`graphql-errors`,message:c};let l=$O(a.data);if(!l)return{ok:!1,failure:`unreadable`,message:`Netflix answered no data`};if(!Array.isArray(l.videos))return{ok:!1,failure:`unreadable`,message:`Netflix answered no videos list`};let u=$O(l.videos[0]);if(!u)return{ok:!0,episodes:[],hasNextPage:!1,empty:`no-such-season`};let d=$O(u.episodes);if(!d)return{ok:!1,failure:`unreadable`,message:`Netflix answered a season with no episodes connection`};let f=$O(d.pageInfo),p=ek(d.edges).map(hk).filter(e=>!!e),m=$O(u.parentShow)?.isAvailable===!1;return{ok:!0,episodes:p,...p.length?{}:{empty:m?`not-in-this-catalogue`:`no-episodes-listed`},hasNextPage:f?.hasNextPage!==!1,endCursor:nk(f?.endCursor)}},vk=async(e,t)=>{let n=Number(e);if(!Number.isFinite(n))return{ok:!1,failure:`unreadable`,message:`not a Netflix season id: ${e}`};let r=[],i=new Set,a;for(let e=0;e<20;e+=1){let e=await _k(n,a,t);if(!e.ok)return e;let o=e.episodes.filter(e=>!i.has(e.videoId));for(let e of o)i.add(e.videoId);if(r.push(...o),!e.hasNextPage)return{ok:!0,episodes:r,truncated:!1,...r.length?{}:{empty:e.empty}};if(!e.endCursor||e.endCursor===a||!o.length)return{ok:!0,episodes:r,truncated:!0};a=e.endCursor}return{ok:!0,episodes:r,truncated:!0}};var yk=c({categories:()=>Ck,filmDatedAnotherYear:()=>gA,getMedia:()=>cA,icon:()=>xk,isApiOnly:()=>!1,linkNetflix:()=>mA,metadataOnly:()=>!0,name:()=>wk,official:()=>!1,origin:()=>`nf`,originUrl:()=>Sk,parseUnogsSeasons:()=>Bk,resetUnogsCaches:()=>Gk,resolvers:()=>bA,runYearDate:()=>hA,searchNodes:()=>sA,supportedUris:()=>Tk});const bk=.2,xk=`https://assets.nflxext.com/us/ffe/siteui/common/icons/nficon2023.ico`,Sk=`https://www.netflix.com`,Ck=[`SERIES`,`MOVIE`],wk=`Netflix`,Tk=[`nf`];let Ek,Dk=0,Ok;var kk=class extends Error{scope;constructor(e,t){super(e),this.name=`UnogsCallError`,this.scope=t}};const Ak=e=>e instanceof kk?e.scope:`title`,jk=e=>{throw e instanceof kk?e:new kk(String(e),`upstream`)},Mk=async e=>Ek&&Date.now()<Dk?Ek:Ok||(Ok=(async()=>{let t=await e.fetch(`https://unogs.com/api/user`,{headers:{accept:`application/json`,"content-type":`application/x-www-form-urlencoded; charset=UTF-8`,"x-requested-with":`XMLHttpRequest`},body:`user_name=anonymous`,method:`POST`,mode:`cors`,credentials:`include`}).then(e=>e.json());if(!t.token?.access_token)throw new kk(`uNoGS token fetch failed: ${JSON.stringify(t)}`,`upstream`);return Dk=Date.now()+720*60*1e3,Ek=t.token.access_token})().finally(()=>{Ok=void 0}),Ok),Nk=()=>{Ek=void 0,Dk=0},Pk=new Map,Fk=(e,t)=>{let n=Pk.get(e);if(n)return n;let r=t();return Pk.set(e,r),r.finally(()=>Pk.delete(e)).catch(()=>{}),r},Ik=(e,t,{requireOk:n=!1}={})=>Fk(e,()=>Mk(t).catch(jk).then(r=>t.fetch(e,{headers:{accept:`application/json`,authorization:`Bearer ${r}`,REFERRER:`http://unogs.com`,referer:`http://unogs.com`},mode:`cors`,credentials:`include`}).catch(jk).then(t=>{if(n&&t.ok===!1)throw Nk(),new kk(`uNoGS answered ${t.status} for ${e}`,`title`);return t.json()}))),Lk=`https://unogs.com/api`,Rk=(e,t)=>Ik(`${Lk}/title/detail?netflixid=${e}`,t),zk=(e,t)=>Ik(`${Lk}/title/bgimages?netflixid=${e}`,t),Bk=e=>{if(!Array.isArray(e))return;let t=[];for(let n of e){let e=n;if(typeof e?.season!=`number`||!Array.isArray(e.episodes))return;let r=e.episodes.map(t=>{if(typeof t!=`object`||!t)return;let n=t;if(!(n.epid==null||n.epid===``))return{epid:n.epid,seasid:typeof n.seasid==`number`?n.seasid:void 0,epnum:typeof n.epnum==`number`?n.epnum:void 0,seasnum:typeof n.seasnum==`number`?n.seasnum:e.season,synopsis:typeof n.synopsis==`string`?n.synopsis:``,title:typeof n.title==`string`?n.title:``,img:typeof n.img==`string`?n.img:``}}).filter(e=>!!e);t.push({season:e.season,seasonId:r.find(e=>e.seasid!=null)?.seasid,episodes:Vk(r)})}return t},Vk=e=>{let t=new Set(e.map(e=>e.epnum));return t.has(void 0)||t.size!==e.length?e:[...e].sort((e,t)=>e.epnum-t.epnum)},Hk=e=>{let t=new Set,n=e=>{let n=e;for(;t.has(n);)n+=1;return t.add(n),n},r=[];return e.forEach((e,t)=>{e.number!=null&&(r[t]=n(e.number))}),e.forEach((e,t)=>{e.number??(r[t]=n(t+1))}),r},Uk=e=>{let t=Hk(e.seasons);return{truncated:e.seasonsTruncated,seasons:e.seasons.map((e,n)=>{let r=t[n];return{season:r,seasonId:e.videoId,truncated:e.truncated,episodes:e.episodes.map(t=>({epid:t.videoId,seasid:e.videoId,epnum:t.number,seasnum:r,synopsis:t.synopsis??``,title:t.title,img:t.thumbnail??``}))}})}};let Wk=0;const Gk=()=>{Nk(),Wk=0,Pk.clear()},Kk=async(e,t)=>{if(!(Date.now()<Wk))try{let n=Bk(await Ik(`${Lk}/title/episodes?netflixid=${e}`,t,{requireOk:!0}));return n||console.error(`uNoGS episodes for ${e} came back in a shape this source cannot read`),n}catch(t){Ak(t)===`upstream`&&(Wk=Date.now()+6e4),console.error(`uNoGS episodes for ${e} failed`,t);return}},qk=(e,t)=>Fk(`netflix:${e}`,async()=>{let n=await dk(e,t);if(!n.ok){console.error(`Netflix fallback for ${e} failed (${n.failure}): ${n.message}`);return}return n.title&&Uk(n.title)}),Jk=async(e,t)=>{let n=await Kk(e,t);return n?.some(e=>e.episodes.length)?{seasons:n,truncated:!1}:await qk(e,t)??{seasons:n??[],truncated:!1}},Yk=/^episode\s+\d+$/i,Xk=(e,t)=>{let n=new Map(t.episodes.map(e=>[String(e.epid),e]));return e.map((e,r)=>{let i=n.get(String(e.videoId))?.title;return{epid:e.videoId,seasid:t.seasonId,epnum:e.number??r+1,seasnum:t.season,synopsis:e.synopsis??``,title:Yk.test(e.title)&&i&&!Yk.test(i)?i:e.title,img:e.thumbnail??``,runtimeSec:e.runtimeSec}})},Zk=async(e,t,n)=>{if(t==null)return e;let r=e.seasons.find(e=>e.season===t),i=r?.seasonId;if(!r||i==null)return console.warn(`Netflix episodes for season ${t} skipped (ours, off unOGS' own listing: ${r?`the listing carries no seasid for it`:`no season ${t} in a listing of ${e.seasons.length}`}); unOGS' own episodes stand`),e;let a=await Fk(`netflix-season:${i}`,()=>vk(i,n));if(!a.ok)return console.error(`Netflix episodes for season ${i} failed (${a.failure}, whose fact: ${QO[a.failure]}): ${a.message}`),e;if(!a.episodes.length)return console.warn(`Netflix episodes for season ${i} answered no episodes (${a.empty??`unstated`}, whose fact: ${a.empty?gk[a.empty]:`unstated, which is this file having lost track of a shape`}); unOGS' own ${r.episodes.length} episode(s) stand`),e;let o=Xk(a.episodes,r);console.warn(`Netflix episodes for season ${i} published ${o.length} episode(s), ${o.filter(e=>e.synopsis.trim()).length} with a synopsis${a.truncated?` (truncated)`:``} (whose fact: Netflix's, answered to this browser's own address)`);let s={...r,episodes:o,truncated:a.truncated};return{...e,seasons:e.seasons.map(e=>e===r?s:e)}},Qk=async(e,t,n)=>Zk(await Jk(e,t),n,t),$k=(e,t)=>Ik(`${Lk}/search?limit=50&offset=0&query=${encodeURIComponent(e)}&countrylist=&country_andorunique=&start_year=&end_year=&start_rating=&end_rating=&genrelist=&type=&audio=&subtitle=&audiosubtitle_andor=&person=&personid=&filterby=&orderby=`,t),eA=e=>e.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(Number(t))).replace(/&#x([0-9a-fA-F]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`).replace(/&apos;/g,`'`).replace(/&#39;/g,`'`),tA=e=>e.replace(/^http:/,`https:`),nA=e=>e===`movie`?`RUN`:`CONTAINER`,rA=(e,t)=>{let n=[],r=[];if(e.img&&n.push({url:tA(e.img),score:bk}),t){let e=t.bo166x236?.[0]?.url;e&&!n.some(t=>t.url===e)&&n.push({url:e,score:bk});let i=t.bo665x375?.[0]?.url??t.bo342x192?.[0]?.url;i&&r.push({url:i,score:bk});let a=t.bg?.[0]?.url;a&&r.push({url:a,score:bk})}return e.lgimg&&!r.some(t=>t.url===e.lgimg)&&r.push({url:e.lgimg,score:bk}),H({origin:`nf`,id:String(e.netflixid),url:`https://www.netflix.com/title/${e.netflixid}`,score:bk,scope:nA(e.vtype),categories:e.vtype===`movie`?[`MOVIE`]:[`SERIES`],titles:[{language:`en`,title:eA(e.title),score:bk}],...uT(e.synopsis?eA(e.synopsis):void 0,bk),covers:n,banners:r,startDate:e.year?`${e.year}-01-01`:void 0,averageScore:nE(e.imdbrating,10)})},iA=e=>H({origin:`nf`,id:String(e.nfid),url:`https://www.netflix.com/title/${e.nfid}`,score:bk,scope:nA(e.vtype),categories:e.vtype===`movie`?[`MOVIE`]:[`SERIES`],titles:[{language:`en`,title:eA(e.title),score:bk}],...uT(e.synopsis?eA(e.synopsis):void 0,bk),covers:e.img?dT(tA(e.img),bk):[],startDate:e.year?`${e.year}-01-01`:void 0}),aA=(e,t,n)=>{let r=e.synopsis?.trim(),i=r&&!r.startsWith(`THIS EPISODE'S SYNOPSIS IS COMING SOON`)?eA(r):void 0;return oT({origin:`nf`,id:String(e.epid),mediaUri:t,url:`https://www.netflix.com/watch/${e.epid}`,score:bk,titles:[{language:`en`,title:eA(e.title),score:bk}],...uT(i,bk),thumbnails:e.img?dT(tA(e.img),bk):[],runtime:e.runtimeSec?Math.round(e.runtimeSec/60):void 0,seasonNumber:e.seasnum,episodeNumber:n})},oA=e=>sT(e,{url:`https://www.netflix.com/watch/${e.id}`,score:bk}),sA=async(e,t)=>{let{results:n=[]}=await $k(e,t);return n.filter(e=>e.vtype===`movie`).map(iA)},cA=async(e,t,n,r=!1)=>{let[i,a]=await Promise.all([Rk(e,t),zk(e,t)]),o=i[0];if(!o||r&&n==null&&o.vtype===`series`)return;let s=o.vtype===`series`?await Qk(e,t,n):void 0;return lA(o,a,s,n)},lA=(e,t,n,r)=>{let i=rA(e,t);if(r!=null&&(i.id=`${i.id}-${r}`,i.uri=BS({origin:`nf`,id:i.id}),i.scope=`RUN`,i.startDate=void 0),e.vtype===`series`){if(!n)return i;let e=r==null?n.seasons:n.seasons.filter(e=>e.season===r);if(r!=null&&!e.length&&n.truncated)return;i.episodes=e.flatMap(e=>e.episodes.map((e,t)=>aA(e,i.uri,t+1))),i.episodeCount=i.episodes.length>0&&!e.some(e=>e.truncated)?i.episodes.length:void 0}else i.episodes=[oA(i)],i.episodeCount=1;return i},uA=(e,t)=>[...e].sort((e,t)=>e.season-t.season).map((e,n)=>({season:e,seasonNumber:e.season,episodeCount:e.truncated?void 0:e.episodes.length,episodeTitles:e.truncated?void 0:e.episodes.map(e=>eA(e.title??``)),year:n===0&&Number(t)||void 0})),dA=async(e,t,n,r)=>{let i=await UT(t,n,e=>pT(e)?e:void 0);if(!i)return;let{seasons:a}=await Qk(e,n);if(!a.length)return;let o=ZD({titles:(i.titles??[]).map(e=>e.title),episodeCount:pT(i),startDate:i.startDate},uA(a,r));return o?{kind:`season`,season:o.season.season}:{kind:`title`}},fA=async(e,t)=>{if(!e?.showId)return;let n=(await Rk(e.showId,t))?.[0];if(n?.vtype!==`series`)return;let r=await Qk(e.showId,t);if(!r.seasons.length)return;let i=ZD(e,uA(r.seasons,n.year));if(!i)return;let a=await Zk(r,i.season.season,t);return lA(n,await zk(e.showId,t),a,i.season.season)},pA=async(e,t)=>{if(!e?.showId)return;let n=(await Rk(e.showId,t))?.[0];if(n?.vtype!==`series`)return;let r=await Qk(e.showId,t);if(!r.seasons.length||r.truncated)return;let i=QD(e,uA(r.seasons,n.year));if(!i)return;console.warn(`similarMedia: nf season ${i.season.season} of ${e.showId} holds this run by ${i.rule} (${i.theirs} episodes over ${i.ours})`);let a=await Zk(r,i.season.season,t);return lA(n,await zk(e.showId,t),a,i.season.season)},mA=async(e,t,n,r,i)=>{let a=r===void 0?(await Rk(e,n))[0]:void 0;if((r??a?.vtype)!==`series`)return cA(e,n,void 0,!0);let o=await dA(e,t,n,i??a?.year);if(!o)return;if(o.kind===`season`)return cA(e,n,o.season,!0);let s=await cA(e,n,void 0,!1);if(s)return s.episodes=[],s.episodeCount=void 0,s},hA=e=>e?.seasonYear?`${e.seasonYear}-01-01`:e?.startDate??void 0,gA=(e,t)=>{if(e.vtype!==`movie`||!t)return!1;let n=Number(e.year);return n?!kD(t,Array.from({length:3},(e,t)=>n-1+t)):!1},_A=async(e,t,n,r,i)=>{for(let a of[e,...BT(e)]){let{results:e=[]}=await $k(a,n);if(!e.length)continue;let o=await AT(a,e.filter(e=>!gA(e,i)).map(e=>({result:e,title:eA(e.title),categories:e.vtype===`movie`?[`MOVIE`]:[`SERIES`]})),r);if(!o)continue;let s=String(o.result.nfid),c=await mA(s,t,n,o.result.vtype,o.result.year);if(c)return c.handles=VT(t,`nf`),c}return null},vA=e=>{let t=e.indexOf(`-`);if(t===-1)return{showId:e};let n=Number(e.slice(t+1));return{showId:e.slice(0,t),season:Number.isFinite(n)?n:void 0}},yA=async(e,t)=>{let n=LS(e,`nf`);if(n){let{showId:r,season:i}=vA(n.id),a=i!=null||!qS(e)?await cA(r,t,i,qS(e)):await mA(r,e,t);return a?(qS(e)&&(a.handles=VT(e,`nf`)),a):null}if(!qS(e))return null;let r=await UT(e,t,e=>fT(e)?e:void 0,3e4),i=fT(r);return i?_A(i,e,t,r?.categories,hA(r)):null},bA={Subscription:{similarMedia:{subscribe:async function*(e,{input:t},n){yield{similarMedia:await fA(t,n)??null}}},containingMedia:{subscribe:async function*(e,{input:t},n){yield{containingMedia:await pA(t,n)??null}}},media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};yield{media:await yA(t,n)}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await sA(t,n)}}}}},Media:{episodes:async(e,t,n)=>{if(e.origin!==`nf`)return e.episodes??[];if(e.episodes?.length)return e.episodes;if(cT(e))return[oA(e)];let{showId:r,season:i}=vA(e.id),{seasons:a}=await Qk(r,n,i);return(i==null?a:a.filter(e=>e.season===i)).flatMap(t=>t.episodes.map((t,n)=>aA(t,e.uri,n+1)))}}},xA=(e,t)=>`${e}-${t}`,SA=e=>{let t=/^(\d+)-(\d+)$/.exec(e);return t?{objectId:t[1],seasonObjectId:Number(t[2])}:{objectId:e}},CA=e=>e!==`MOVIE`,wA=(e,t)=>e===`cr`?void 0:t,TA={cru:`cr`,nfx:`nf`,nfa:`nf`,dnp:`disney`,amp:`amazon`,atp:`appletv`,hlu:`hulu`,mxx:`hbo`,pcp:`peacock`,pct:`peacock`,ppp:`paramount`,ppe:`paramount`,fuv:`fubo`},EA=e=>{try{let t=new URL(e),n=t.hostname.replace(`www.`,``),r=t.pathname.split(`/`).filter(Boolean);if(n===`netflix.com`||n===`crunchyroll.com`&&r[0]===`series`)return r[1];if(n.startsWith(`amazon.`)||n.endsWith(`.amazon.com`))return t.searchParams.get(`gti`)??(n.startsWith(`amazon.`)?r.at(-1):void 0);if(n===`hulu.com`){let e=r.at(-1);return e?.match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i)?.[1]??e}if(n===`tv.apple.com`)return t.searchParams.get(`showId`)??r.find(e=>e.startsWith(`umc.`));if(n===`disneyplus.com`){let e=r.find(e=>e.startsWith(`entity-`));return e?e.slice(7):r[0]===`play`?r[1]:r[2]}if(n===`peacocktv.com`)return r[2]===`tv`?r[4]:r.at(-1);if(n===`paramountplus.com`)return r[1];if(n===`fubo.tv`)return r[0]===`welcome`?r[2]:void 0;if(n===`play.hbomax.com`||n===`hbomax.com`)return r[0]===`video`?r[2]:r[1]}catch{}},DA={MEDIA:{crossSource:!0},MEDIA_PAGE:{crossSource:!1},SIMILAR_MEDIA:{crossSource:!0}},OA={crossSource:!0};let kA=0;const AA=new Map;let jA=0;const MA=e=>{let t=`r${++jA}`;return PA({rootId:t,operation:e,chain:[]})},NA=(e,t)=>PA({rootId:e.rootId,operation:e.operation,chain:[...e.chain,t]}),PA=({rootId:e,operation:t,chain:n})=>{let r={token:`t${++jA}`,rootId:e,operation:t,chain:n};return AA.set(r.token,r),r},FA=e=>typeof e==`string`?AA.get(e):void 0,IA=e=>{for(let[t,n]of AA)n.rootId===e&&AA.delete(t)},LA=e=>{let t=e?.context?.token,n=FA(t);return n||kA++,n},RA=e=>{let t=LA(e);return t?DA[t.operation]:OA},zA=(e,t)=>{let n=e.input;return typeof n!=`object`||!n?e:{...e,input:{...n,context:t}}};var BA=c({categories:()=>WA,icon:()=>HA,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>GA,official:()=>!1,origin:()=>`jw`,originUrl:()=>UA,resolvers:()=>pj,showAsContainer:()=>aj,supportedUris:()=>KA});const VA=.2,HA=`https://www.justwatch.com/appasset/img/favicon/favicon-32x32.png`,UA=`https://www.justwatch.com`,WA=[`SERIES`,`MOVIE`],GA=`JustWatch`,KA=[`jw`],qA={primary:`US`,extra:`JP`},JA=e=>{try{let t=new URL(e);return t.searchParams.get(`u`)??t.searchParams.get(`r`)??void 0}catch{}},YA=e=>{try{let{hostname:t,pathname:n}=new URL(e);if(t.replace(`www.`,``)!==`crunchyroll.com`)return;let r=n.split(`/`).filter(Boolean);return r[0]===`watch`?r[1]:void 0}catch{}},XA=async(e,t,n)=>(await n.fetch(`https://apis.justwatch.com/graphql`,{method:`POST`,headers:{"content-type":`application/json`,accept:`*/*`},body:JSON.stringify({query:e,variables:t})})).json(),ZA=new Map,QA=async(e,t)=>{let n=ZA.get(e);if(n)return n;let r=t();return ZA.set(e,r),r.finally(()=>ZA.delete(e)),r},$A=(e,t)=>QA(`search:${e}`,()=>XA(`
1114
+ query GetSearchTitles($searchTitlesFilter: TitleFilter!, $country: Country!, $extraCountry: Country!, $language: Language!, $first: Int!) {
1115
+ popularTitles(country: $country, filter: $searchTitlesFilter, first: $first, sortBy: POPULAR, sortRandomSeed: 0) {
1116
+ edges {
1117
+ node {
1118
+ id
1119
+ objectId
1120
+ objectType
1121
+ content(country: $country, language: $language) {
1122
+ title
1123
+ fullPath
1124
+ originalReleaseYear
1125
+ originalReleaseDate
1126
+ shortDescription
1127
+ posterUrl(profile: S718, format: JPG)
1128
+ externalIds {
1129
+ imdbId
1130
+ }
1131
+ genres {
1132
+ shortName
1133
+ }
1134
+ }
1135
+ offers(country: $country, platform: WEB, filter: { bestOnly: true }) {
1136
+ monetizationType
1137
+ presentationType
1138
+ standardWebURL
1139
+ package {
1140
+ id
1141
+ packageId
1142
+ clearName
1143
+ technicalName
1144
+ shortName
1145
+ icon(profile: S100)
1146
+ }
1147
+ }
1148
+ extraOffers: offers(country: $extraCountry, platform: WEB, filter: { bestOnly: true }) {
1149
+ monetizationType
1150
+ presentationType
1151
+ standardWebURL
1152
+ package {
1153
+ id
1154
+ packageId
1155
+ clearName
1156
+ technicalName
1157
+ shortName
1158
+ icon(profile: S100)
1159
+ }
1160
+ }
1161
+ ... on Show {
1162
+ seasons(sortDirection: ASC) {
1163
+ objectId
1164
+ totalEpisodeCount
1165
+ content(country: $country, language: $language) {
1166
+ seasonNumber
1167
+ isReleased
1168
+ }
1169
+ }
1170
+ }
1171
+ }
1172
+ }
1173
+ }
1174
+ }
1175
+ `,{first:10,searchTitlesFilter:{searchQuery:e},language:`en`,country:qA.primary,extraCountry:qA.extra},t)),ej=(e,t)=>QA(`node:${e}`,()=>XA(`
1176
+ query GetTitleNode($nodeId: ID!, $language: Language!, $country: Country!, $extraCountry: Country!) {
1177
+ node(id: $nodeId) {
1178
+ ... on MovieOrShow {
1179
+ id
1180
+ objectId
1181
+ objectType
1182
+ content(country: $country, language: $language) {
1183
+ title
1184
+ fullPath
1185
+ originalReleaseYear
1186
+ originalReleaseDate
1187
+ shortDescription
1188
+ posterUrl(profile: S718, format: JPG)
1189
+ externalIds {
1190
+ imdbId
1191
+ }
1192
+ genres {
1193
+ shortName
1194
+ }
1195
+ }
1196
+ offers(country: $country, platform: WEB, filter: { bestOnly: true }) {
1197
+ monetizationType
1198
+ presentationType
1199
+ standardWebURL
1200
+ package {
1201
+ id
1202
+ packageId
1203
+ clearName
1204
+ technicalName
1205
+ shortName
1206
+ icon(profile: S100)
1207
+ }
1208
+ }
1209
+ extraOffers: offers(country: $extraCountry, platform: WEB, filter: { bestOnly: true }) {
1210
+ monetizationType
1211
+ presentationType
1212
+ standardWebURL
1213
+ package {
1214
+ id
1215
+ packageId
1216
+ clearName
1217
+ technicalName
1218
+ shortName
1219
+ icon(profile: S100)
1220
+ }
1221
+ }
1222
+ ... on Show {
1223
+ totalSeasonCount
1224
+ seasons(sortDirection: ASC) {
1225
+ id
1226
+ objectId
1227
+ totalEpisodeCount
1228
+ content(country: $country, language: $language) {
1229
+ title
1230
+ seasonNumber
1231
+ fullPath
1232
+ posterUrl
1233
+ originalReleaseYear
1234
+ originalReleaseDate
1235
+ isReleased
1236
+ }
1237
+ episodes(limit: 50) {
1238
+ id
1239
+ objectId
1240
+ content(country: $country, language: $language) {
1241
+ title
1242
+ episodeNumber
1243
+ seasonNumber
1244
+ isReleased
1245
+ shortDescription
1246
+ originalReleaseDate
1247
+ runtime
1248
+ }
1249
+ flatrate: offers(
1250
+ country: $country, platform: WEB,
1251
+ filter: { monetizationTypes: [FLATRATE_AND_BUY, FLATRATE, ADS, FREE], bestOnly: true }
1252
+ ) {
1253
+ package {
1254
+ clearName
1255
+ packageId
1256
+ shortName
1257
+ }
1258
+ }
1259
+ }
1260
+ }
1261
+ }
1262
+ }
1263
+ }
1264
+ }
1265
+ `,{nodeId:e,language:`en`,country:qA.primary,extraCountry:qA.extra},t)),tj=e=>e?e.startsWith(`http`)?e:`https://images.justwatch.com${e}`:void 0,nj=(e,t)=>e??(t?`${t}-01-01`:void 0),rj=e=>e.map(e=>({season:e,seasonNumber:e.content.seasonNumber,episodeCount:e.totalEpisodeCount||void 0,year:e.content.originalReleaseYear,episodeTitles:(e.episodes??[]).map(e=>e.content.title)})),ij=async(e,t,n,r=OA)=>{let i=new Set,a=[];for(let o of e){if(![`FLATRATE`,`FLATRATE_AND_BUY`,`FREE`,`ADS`].includes(o.monetizationType))continue;let e=TA[o.package.shortName];if(!e||i.has(e))continue;i.add(e);let s=(o.standardWebURL?JA(o.standardWebURL):void 0)??o.standardWebURL??void 0,c,l=`SAME_AS`,u=s?EA(s):void 0;if(!u&&e===`cr`&&s&&t.seasonNumber==null&&!t.showContainer&&r.crossSource){let e=YA(s);if(e){let t=await EO(e,n);t&&(c=kO(t.seriesId,t.seasonId))}}else u&&(c=wA(e,u),c?t.seasonNumber!=null&&(l=`PART_OF`):e===`cr`&&(c=u,l=`PART_OF`));if(!c)continue;let d=H({origin:e,id:c,url:s});a.push(l===`PART_OF`?iT(d):rT(d))}return a},aj=async(e,t,n=OA)=>{let r=await ij([...e.offers??[],...e.extraOffers??[]],{showContainer:!0},t,n);return r.length?H({origin:`jw`,id:String(e.objectId),url:`https://www.justwatch.com${e.content.fullPath}`,scope:`CONTAINER`,categories:[e.objectType===`MOVIE`?`MOVIE`:`SERIES`],score:VA,handles:r,titles:[{language:`en`,title:e.content.title,score:VA}],...uT(e.content.shortDescription??void 0,VA),covers:dT(tj(e.content.posterUrl),VA),startDate:nj(e.content.originalReleaseDate,e.content.originalReleaseYear)}):null},oj=async(e,t,n,r=OA)=>{if(t.seasonNumber==null&&CA(e.objectType))return null;let i=(t.seasons??[]).find(e=>e.content.seasonNumber===t.seasonNumber);if(t.seasonNumber!=null&&i?.objectId==null)return null;let a=t.seasonNumber==null?String(e.objectId):xA(e.objectId,i.objectId),{shortDescription:o}=e.content,s=i?.content?.originalReleaseYear??e.content.originalReleaseYear,c=i?i.content.originalReleaseDate:e.content.originalReleaseDate,l=i?.content.title&&!Jw(i.content.title)?i.content.title:e.content.title,u=t.seasonNumber==null?t.seasons??[]:(t.seasons??[]).filter(e=>e.content.seasonNumber===t.seasonNumber),d=u.flatMap(e=>(e.episodes??[]).filter(e=>e.content.isReleased).map(e=>sj(e,BS({origin:`jw`,id:a})))),f=await ij([...e.offers??[],...e.extraOffers??[]],{seasonNumber:t.seasonNumber},n,r);t.seasonNumber!=null&&f.push(iT(H({origin:`jw`,id:String(e.objectId),url:`https://www.justwatch.com${e.content.fullPath}`,categories:[e.objectType===`MOVIE`?`MOVIE`:`SERIES`],titles:[{language:`en`,title:e.content.title,score:VA}],startDate:nj(e.content.originalReleaseDate,e.content.originalReleaseYear)})));let p=H({origin:`jw`,id:a,categories:[e.objectType===`MOVIE`?`MOVIE`:`SERIES`],url:`https://www.justwatch.com${e.content.fullPath}`,score:VA,handles:f,episodes:d,titles:l?[{language:`en`,title:l,score:VA}]:[],episodeCount:d.length||u.reduce((e,t)=>e+(t.totalEpisodeCount??0),0)||void 0,startDate:nj(c,s)});return cT(p)&&(p.episodes=[sT(p,{score:VA,...uT(o,VA)})],p.episodeCount=1),p},sj=(e,t)=>oT({origin:`jw`,id:String(e.objectId),mediaUri:t,score:VA,titles:[{language:`en`,title:e.content.title,score:VA}],...uT(e.content.shortDescription,VA),releaseDate:e.content.originalReleaseDate??void 0,seasonNumber:e.content.seasonNumber,episodeNumber:e.content.episodeNumber,runtime:e.content.runtime??void 0}),cj=async(e,t,n)=>{if(!t.seasons?.length)return;let r=rj(t.seasons);return UT(e,n,e=>{let t={titles:(e?.titles??[]).map(e=>e.title),episodeCount:pT(e),startDate:e?.startDate};return PD(t)?ZD(t,r)?.season.content.seasonNumber:void 0})},lj=async(e,t)=>{if(!e?.showId)return;let n=(await ej(`ts${e.showId}`,t)).data?.node;if(!n?.seasons?.length||!CA(n.objectType))return;let r=ZD(e,rj(n.seasons));if(r)return await oj(n,{seasons:n.seasons,seasonNumber:r.season.content.seasonNumber},t,RA(e))??void 0},uj=(e,t)=>{let n=(t.seasons??[]).map(e=>e.content?.originalReleaseYear);return n.length?kD(e,n):!CA(t.objectType)&&kD(e,[t.content.originalReleaseYear])},dj=async(e,t)=>{let n=await UT(e,t,e=>fT(e)&&e?.startDate?e:void 0,3e4);if(!n)return null;let r=n.startDate??void 0;if(!r)return null;let i=(n.titles??[]).map(e=>e.title).filter(Boolean),a=i[0];if(!a)return null;let o=new Map,s=e=>{let n=o.get(e);if(n)return n;let r=ej(e,t);return o.set(e,r),r},c=null;for(let o of ED(a)){let a=((await $A(o,t)).data?.popularTitles?.edges??[]).map(e=>e.node);if(!a.length)continue;let l=await DD(i,a,e=>e.content?.title);if(l.length)for(let{candidate:a}of l){let o=(await s(a.id)).data?.node;if(!o?.content?.title||!uj(r,o))continue;let l=o.seasons?.length?ZD({titles:i,episodeCount:pT(n),startDate:r},rj(o.seasons))?.season.content.seasonNumber:void 0,u=await oj(o,{seasons:o.seasons,seasonNumber:l},t);if(u)return HT(u,e),u;c||=await aj(o,t)}}return c},fj=async(e,t)=>{let n=LS(e,`jw`);if(n){let{objectId:r,seasonObjectId:i}=SA(n.id),a=(await ej(`ts${r}`,t)).data?.node;if(!a)return null;let o=(i==null?void 0:a.seasons?.find(e=>e.objectId===i)?.content.seasonNumber)??(qS(e)?await cj(e,a,t):void 0),s=await oj(a,{seasons:a.seasons,seasonNumber:o},t);return s?(qS(e)&&HT(s,e),s):null}return qS(e)?dj(e,t):null},pj={Subscription:{similarMedia:{subscribe:async function*(e,{input:t},n){yield{similarMedia:await lj(t,n)??null}}},media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};yield{media:await fj(t,n)}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:t},n){let{search:r}=t;if(!r)return yield{mediaPage:{nodes:[]}};let i=RA(t),a=await $A(r,n);yield{mediaPage:{nodes:(await Promise.all((a.data?.popularTitles?.edges??[]).map(e=>oj(e.node,{},n,i)))).filter(e=>e!==null)}}}}},Media:{episodes:async(e,t,n)=>{if(e.origin!==`jw`)return e.episodes??[];if(e.episodes?.length)return e.episodes;if(cT(e))return[sT(e,{score:VA})];let{objectId:r,seasonObjectId:i}=SA(e.id),a=(await ej(`ts${r}`,n)).data?.node;if(!a?.seasons)return[];let o=(i==null?void 0:a.seasons.find(e=>e.objectId===i)?.content.seasonNumber)??(e.titles?.[0]?.title?Yw(e.titles[0].title):void 0);return(o==null?a.seasons:a.seasons.filter(e=>e.content.seasonNumber===o)).flatMap(t=>(t.episodes??[]).filter(e=>e.content.isReleased).map(t=>sj(t,e.uri)))}}};var mj=c({categories:()=>vj,color:()=>Sj,icon:()=>gj,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>yj,official:()=>!1,origin:()=>bj,originUrl:()=>_j,resolvers:()=>Rj,supportedUris:()=>xj});const hj=.2,gj=`https://tv.apple.com/favicon.ico`,_j=`https://tv.apple.com`,vj=[`SERIES`,`MOVIE`],yj=`Apple TV+`,bj=`appletv`,xj=[`appletv`],Sj=`#e8e8ed`,Cj=(e,t)=>t.fetch(`https://uts-api.itunes.apple.com/uts/v3${e}${e.includes(`?`)?`&`:`?`}caller=web&sf=143441&v=58&pfm=web&locale=en-US&utsk=0`).then(e=>e.json()),wj=(e,t,n)=>e?.url?.replace(`{w}`,String(t)).replace(`{h}`,String(n)).replace(`{c}`,``).replace(`{f}`,`jpg`),Tj=(e,t)=>{let n=wj(e.images?.coverArt,600,900),r=wj(e.images?.coverArt16X9,1920,1080),i=t?.seasonNumber!=null,a=i?t.releaseDate:e.releaseDate,o=i||e.type===`Movie`?`RUN`:`CONTAINER`;return H({origin:bj,id:i?Qw(e.id,t.seasonNumber):e.id,scope:o,url:e.url,score:hj,categories:e.type===`Movie`?[`MOVIE`]:[`SERIES`],titles:[{language:`en`,title:e.title,score:hj}],...uT(e.description,hj),covers:dT(n,hj),banners:dT(r,hj),startDate:a==null?void 0:new Date(a).toISOString()})},Ej=(e,t)=>oT({origin:bj,id:e.id,mediaUri:t,url:e.url,score:hj,titles:[{language:`en`,title:e.title,score:hj}],...uT(e.description,hj),thumbnails:dT(wj(e.images?.previewFrame??e.images?.coverArt16X9,1280,720),hj),seasonNumber:e.seasonNumber,episodeNumber:e.episodeNumber,releaseDate:e.releaseDate==null?void 0:new Date(e.releaseDate).toISOString()}),Dj=async(e,t,n,r,i)=>{let a=Object.values(t??{}).filter(e=>i==null||e.seasonNumber===i).map(e=>e.id).filter(Boolean);if(!a.length)return[];let o=await Promise.all(a.map(t=>Cj(`/shows/${e}/episodes?selectedSeasonId=${t}`,r).then(e=>e.data?.episodes??[]).catch(()=>[]))),s=new Map;for(let e of o.flat())i!=null&&e.seasonNumber!==i||s.has(e.id)||s.set(e.id,e);return[...s.values()].sort((e,t)=>(e.seasonNumber??0)-(t.seasonNumber??0)||(e.episodeNumber??0)-(t.episodeNumber??0)).map(e=>Ej(e,n))},Oj=async(e,t)=>{let n=await Cj(`/shows/${e}`,t);if(n.data?.content)return n.data;let r=await Cj(`/movies/${e}`,t);return r.data?.content?r.data:void 0},kj=e=>Object.values(e.seasons??{}).filter(e=>e.seasonNumber!=null).map(e=>({season:e,seasonNumber:e.seasonNumber,premiere:e.releaseDate})),Aj=async(e,t,n,r)=>{if(n!=null)return t.find(({season:e})=>e.seasonNumber===n)?.season;if(t.length)return UT(e,r,e=>ZD({titles:(e?.titles??[]).map(e=>e.title),startDate:e?.startDate,episodeCount:pT(e)},t)?.season)},jj=async(e,t,n)=>{let r=e.content;if(!r)return;if(r.type===`Movie`){let e=Tj(r);return e.episodes=[sT(e)],e.episodeCount=1,e}if(t?.seasonNumber==null)return Tj(r);let i=Tj(r,t);return i.episodes=await Dj(r.id,e.seasons,i.uri,n,t.seasonNumber),i.episodeCount=i.episodes.length,i},Mj=async(e,t)=>{let n=await Oj(e.showId,t);if(!n?.content||n.content.type===`Movie`)return;let r=ZD(e,kj(n));return r?jj(n,r.season,t):void 0},Nj=async(e,t,n,r)=>{let i=await Oj(t,r);if(!i?.content)return;let a=await Aj(e,kj(i),n,r);return jj(i,a,r)},Pj=async(e,t)=>{let n=((await Cj(`/search?searchTerm=${encodeURIComponent(e)}`,t)).data?.canvas?.shelves??[]).flatMap(e=>e.items??[]).filter(e=>e.type===`Show`||e.type===`Movie`),r=new Map;for(let e of n)r.has(e.id)||r.set(e.id,e);return[...r.values()]},Fj=e=>e?.content?e.content.type===`Movie`?[{id:e.content.id,releaseDate:e.content.releaseDate}]:Object.values(e.seasons??{}):[],Ij=async(e,t)=>{let n=await UT(e,t,e=>fT(e)&&e?.startDate?e:void 0,3e4);if(!n)return null;let r=n.startDate??void 0;if(!r)return null;let i=(n.titles??[]).map(e=>e.title).filter(Boolean),a=i[0];if(!a)return null;let o=new Map,s=e=>{let n=o.get(e);if(n)return n;let r=Oj(e,t).catch(()=>void 0);return o.set(e,r),r};for(let n of ED(a)){let a=await Pj(n,t);if(!a.length)continue;let o=await jD({titles:i,startDate:r},a,e=>e.title,async e=>Fj(await s(e.id)),e=>e.releaseDate);if(!o)continue;let c=await s(o.candidate.id);if(!c)continue;let l=await jj(c,o.season,t);if(l)return l.handles=VT(e,bj),l}return null},Lj=async(e,t)=>{let n=LS(e,bj);if(n){let{showId:r,seasonNumber:i}=$w(n.id),a=await Nj(e,r,i,t);return a?(qS(e)&&(a.handles=VT(e,bj)),a):null}return qS(e)?Ij(e,t):null},Rj={Subscription:{similarMedia:{subscribe:async function*(e,{input:t},n){if(!t?.showId)return yield{similarMedia:null};yield{similarMedia:await Mj(t,n)??null}}},media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};yield{media:await Lj(t,n)}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:(await Pj(t,n)).map(e=>Tj(e))}}}}},Media:{episodes:async(e,t,n)=>{if(e.origin!==`appletv`)return e.episodes??[];if(e.episodes?.length)return e.episodes;if(cT(e))return[sT(e)];let{showId:r,seasonNumber:i}=$w(e.id),a=await Oj(r,n);return Dj(r,a?.seasons,e.uri,n,i)}}};var zj=c({categories:()=>Uj,color:()=>qj,icon:()=>Vj,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>Wj,official:()=>!1,origin:()=>Gj,originUrl:()=>Hj,resolvers:()=>Zj,supportedUris:()=>Kj});const Bj=.2,Vj=`https://www.paramountplus.com/favicon.ico`,Hj=`https://www.paramountplus.com`,Uj=[`SERIES`],Wj=`Paramount+`,Gj=`paramount`,Kj=[`paramount`],qj=`#0064ff`,Jj=`https://www.paramountplus.com`,Yj=async(e,t,n)=>((await n.fetch(`${Jj}/shows/${e}/xhr/episodes/page/0/size/100000/xs/0/season/0/`).then(e=>e.json()).catch(()=>void 0))?.result?.data??[]).map(e=>oT({origin:Gj,id:e.content_id,mediaUri:t,url:e.url?`${Jj}${e.url}`:void 0,score:Bj,titles:e.title?[{language:`en`,title:e.title,score:Bj}]:[],thumbnails:dT(e.thumbnail,Bj),seasonNumber:e.season_num==null?void 0:Number(e.season_num),episodeNumber:e.episode_num==null?void 0:Number(e.episode_num)})),Xj=async(e,t)=>{let n=H({origin:Gj,id:e,url:`${Jj}/shows/${e}`,score:Bj,scope:`CONTAINER`,categories:[`SERIES`]}),r=await Yj(e,n.uri,t);return new Set(r.map(e=>e.seasonNumber??0)).size<=1&&(n.episodes=r,n.episodeCount=r.length),n},Zj={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,Gj)?.id;yield{media:r?await Xj(r,n):null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}},Media:{episodes:async(e,t,n)=>e.origin===`paramount`?e.episodes?.length?e.episodes:Yj(e.id,e.uri,n):e.episodes??[]}};var Qj=c({categories:()=>tM,color:()=>aM,icon:()=>$j,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>nM,official:()=>!1,origin:()=>rM,originUrl:()=>eM,resolvers:()=>oM,supportedUris:()=>iM});const $j=`https://www.disneyplus.com/favicon.ico`,eM=`https://www.disneyplus.com`,tM=[`SERIES`,`MOVIE`],nM=`Disney+`,rM=`disney`,iM=[`disney`],aM=`#0063e5`,oM={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var sM=c({categories:()=>uM,color:()=>mM,icon:()=>cM,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>dM,official:()=>!1,origin:()=>fM,originUrl:()=>lM,resolvers:()=>hM,supportedUris:()=>pM});const cM=`https://www.primevideo.com/favicon.ico`,lM=`https://www.primevideo.com`,uM=[`SERIES`,`MOVIE`],dM=`Prime Video`,fM=`amazon`,pM=[`amazon`],mM=`#00a8e1`,hM={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var gM=c({categories:()=>yM,color:()=>CM,icon:()=>_M,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>bM,official:()=>!1,origin:()=>xM,originUrl:()=>vM,resolvers:()=>wM,supportedUris:()=>SM});const _M=`https://www.hulu.com/favicon.ico`,vM=`https://www.hulu.com`,yM=[`SERIES`,`MOVIE`],bM=`Hulu`,xM=`hulu`,SM=[`hulu`],CM=`#1ce783`,wM={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var TM=c({categories:()=>OM,color:()=>MM,icon:()=>EM,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>kM,official:()=>!1,origin:()=>AM,originUrl:()=>DM,resolvers:()=>NM,supportedUris:()=>jM});const EM=`https://www.peacocktv.com/favicon.ico`,DM=`https://www.peacocktv.com`,OM=[`SERIES`,`MOVIE`],kM=`Peacock`,AM=`peacock`,jM=[`peacock`],MM=`#069de0`,NM={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var PM=c({categories:()=>LM,color:()=>zM,icon:()=>FM,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>`Max`,official:()=>!1,origin:()=>`hbo`,originUrl:()=>IM,resolvers:()=>BM,supportedUris:()=>RM});const FM=`https://www.max.com/favicon.ico`,IM=`https://www.max.com`,LM=[`SERIES`,`MOVIE`],RM=[`hbo`],zM=`#7b5cff`,BM={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var VM=c({categories:()=>WM,color:()=>iee,icon:()=>HM,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>GM,official:()=>!1,origin:()=>KM,originUrl:()=>UM,resolvers:()=>aee,supportedUris:()=>qM});const HM=`https://www.fubo.tv/favicon.ico`,UM=`https://www.fubo.tv`,WM=[`SERIES`,`MOVIE`],GM=`Fubo`,KM=`fubo`,qM=[`fubo`],iee=`#fa4616`,aee={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var oee=c({categories:()=>lee,color:()=>fee,icon:()=>see,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>uee,official:()=>!1,origin:()=>XM,originUrl:()=>cee,resolvers:()=>pN,supportedUris:()=>dee});const JM=.3,YM=`https://www.themoviedb.org`,see=`https://www.themoviedb.org/favicon.ico`,cee=`https://www.themoviedb.org`,lee=[`SERIES`],uee=`TMDB`,XM=`tmdb`,dee=[`tmdb`],fee=`#01b4e4`,pee={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:` `},ZM=e=>e.replace(/&#x([0-9a-f]+);/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t))).replace(/&([a-z]+);/gi,(e,t)=>pee[t.toLowerCase()]??e),QM=(e,t)=>t.fetch(`${YM}${e}`).then(e=>e.text()).catch(()=>void 0),$M=(e,t)=>e.match(RegExp(`<meta property="${t}" content="([^"]*)"`))?.[1],eN=[`january`,`february`,`march`,`april`,`may`,`june`,`july`,`august`,`september`,`october`,`november`,`december`],tN=e=>{let t=e?/^([A-Za-z]+)\s+(\d{1,2}),\s*(\d{4})$/.exec(e.trim()):void 0;if(!t)return;let n=eN.indexOf(t[1].toLowerCase());if(n<0)return;let r=Number(t[2]),i=Number(t[3]),a=new Date(Date.UTC(i,n,r));if(!(a.getUTCMonth()!==n||a.getUTCDate()!==r))return`${String(i).padStart(4,`0`)}-${String(n+1).padStart(2,`0`)}-${String(r).padStart(2,`0`)}`},nN=(e,t)=>{let n=(e.match(RegExp(`href="/tv/${t}(?![0-9])[^"]*"><h2[\\s\\S]{0,400}?class="release_date[^"]*">([^<]*)<`))?.[1])?.match(/\b(?:19|20)\d{2}\b/)?.[0];return n?Number(n):void 0},rN=e=>{let t=[],n=new Set;for(let r of e.matchAll(/data-media-type="tv"[\s\S]{0,200}?href="\/tv\/(\d+)[^"]*"[\s\S]{0,400}?<img\s+alt="([^"]*)"(?:[\s\S]{0,300}?(?:src|data-src)="(https:\/\/[^"]+)")?/g)){let i=r[1];!i||n.has(i)||(n.add(i),t.push({id:i,title:ZM(r[2]??``),poster:r[3],year:nN(e,i)}))}return t},iN=(e,t)=>{let n=e.match(/\/t\/p\/w1920[^"']+\.(?:jpg|png)/)?.[0],r=e.match(/class="user_score_chart"[^>]*data-percent="([\d.]+)"/)?.[1],i=[...new Set([...e.matchAll(RegExp(`/tv/${t}/season/(\\d+)`,`g`))].map(e=>Number(e[1])))].filter(e=>e>0).sort((e,t)=>e-t);return{id:t,title:ZM($M(e,`og:title`)??``),overview:ZM($M(e,`og:description`)??``)||void 0,poster:$M(e,`og:image`),banner:n?`https://media.themoviedb.org${n}`:void 0,score:r?Math.round(Number(r))/10:void 0,seasons:i}},aN=e=>{let t=[];for(let n of e.split(`<div class="card`)){let e=n.match(/data-episode-number="(\d+)"/)?.[1];if(!e)continue;let r=n.match(/<h3><a[^>]*>([^<]+)<\/a><\/h3>/)?.[1]??n.match(/<img[^>]*\balt="([^"]*)"/)?.[1],i=n.match(/class="overview"[^>]*>\s*<p>([\s\S]*?)<\/p>/)?.[1];t.push({number:Number(e),title:r?ZM(r):void 0,overview:i?ZM(i.replace(/<[^>]+>/g,``)).trim():void 0,still:n.match(/src="(https:\/\/media\.themoviedb\.org\/t\/p\/[^"]+)"/)?.[1],releaseDate:tN(n.match(/<span class="date">([^<]*)<\/span>/)?.[1])})}return t},oN=(e,t)=>H({origin:XM,id:t==null?e.id:Qw(e.id,t),scope:t==null?`CONTAINER`:`RUN`,url:`${YM}/tv/${e.id}`,categories:[`SERIES`],score:JM,titles:[{language:`en`,title:e.title,score:JM}],...uT(e.overview,JM),covers:dT(e.poster,JM),banners:dT(e.banner,JM),averageScore:nE(e.score,10),startDate:t==null&&e.year?`${e.year}-01-01`:void 0}),sN=(e,t,n,r)=>oT({origin:XM,id:`${n}-s${t}e${e.number}`,mediaUri:r,score:JM,titles:e.title?[{language:`en`,title:e.title,score:JM}]:[],...uT(e.overview,JM),thumbnails:dT(e.still,JM),seasonNumber:t,episodeNumber:e.number,releaseDate:e.releaseDate}),cN=async(e,t,n)=>Promise.all(t.map(async t=>({seasonNumber:t,episodeCount:await QM(`/tv/${e}/season/${t}?language=en-US`,n).then(e=>e?aN(e).length:0)}))),lN=async(e,t,n,r)=>{if(n.length===1)return n[0];if(!n.length)return;let i=await UT(e,r,e=>{let t=fT(e),n=t?Yw(t):void 0,r=pT(e);return n!=null||r?{season:n,count:r}:void 0});if(i?.season!=null)return i.season;if(i?.count)return Xw(await cN(t,n,r),i.count)},uN=async(e,t,n,r)=>(await Promise.all(t.map(t=>QM(`/tv/${e}/season/${t}?language=en-US`,r).then(r=>r?aN(r).map(r=>sN(r,t,e,n)):[])))).flat(),dN=async(e,t,n,r)=>{let i=await QM(`/tv/${t}?language=en-US`,r);if(!i)return;let a=iN(i,t);if(!a.title)return;let o=n??await lN(e,t,a.seasons,r);if(o==null&&a.seasons.length>1)return;let s=oN(a,o);return s.episodes=await uN(t,o==null?a.seasons:[o],s.uri,r),s.episodeCount=s.episodes.length,s},fN=async(e,t)=>{let n=await QM(`/search/tv?query=${encodeURIComponent(e)}&language=en-US`,t);return n?rN(n).map(e=>oN(e)):[]},pN={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,XM);if(!r)return yield{media:null};let{showId:i,seasonNumber:a}=$w(r.id);yield{media:await dN(t,i,a,n)??null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await fN(t,n)}}}}},Media:{episodes:async(e,t,n)=>{if(e.origin!==`tmdb`)return e.episodes??[];if(e.episodes?.length)return e.episodes;let{showId:r,seasonNumber:i}=$w(e.id),a=await QM(`/tv/${r}?language=en-US`,n);if(!a)return[];let o=i==null?iN(a,r).seasons:[i];return uN(r,o,e.uri,n)}}};var mN=c({categories:()=>vN,color:()=>SN,icon:()=>gN,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>yN,official:()=>!1,origin:()=>bN,originUrl:()=>_N,resolvers:()=>IN,supportedUris:()=>xN});const hN=.3,gN=`https://www.tvmaze.com/favicon.ico`,_N=`https://www.tvmaze.com`,vN=[`SERIES`],yN=`TVmaze`,bN=`tvmaze`,xN=[`tvmaze`],SN=`#3c948b`,CN={amp:`&`,lt:`<`,gt:`>`,quot:`"`,apos:`'`,nbsp:` `},wN=e=>{if(e)return e.replace(/<[^>]+>/g,``).replace(/&#x([0-9a-f]+);/gi,(e,t)=>String.fromCodePoint(parseInt(t,16))).replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t))).replace(/&([a-z]+);/gi,(e,t)=>CN[t.toLowerCase()]??e).trim()||void 0},TN=(e,t)=>t.fetch(`https://api.tvmaze.com${e}`).then(e=>e.json()).catch(()=>void 0),EN=e=>{let t=e.airstamp?new Date(e.airstamp):void 0;return t&&!Number.isNaN(t.getTime())?t.toISOString():e.airdate||void 0},DN=e=>{let t=e.externals?.imdb;return t?[H({origin:`imdb`,id:t,url:`https://www.imdb.com/title/${t}`,scope:`CONTAINER`})]:[]},ON=(e,t,n=[],r)=>H({origin:bN,id:t==null?String(e.id):Qw(e.id,t),scope:t==null?`CONTAINER`:`RUN`,url:e.url??`https://www.tvmaze.com/shows/${e.id}`,handles:n,categories:[`SERIES`],score:hN,titles:e.name?[{language:`en`,title:e.name,score:hN}]:[],...uT(wN(e.summary),hN),covers:dT(e.image?.original??e.image?.medium,hN),startDate:(t==null?e.premiered:r)||void 0,averageScore:e.rating?.average??void 0}),kN=(e,t)=>oT({origin:bN,id:String(e.id),mediaUri:t,score:hN,titles:e.name?[{language:`en`,title:e.name,score:hN}]:[],...uT(wN(e.summary),hN),thumbnails:dT(e.image?.original??e.image?.medium,hN),seasonNumber:e.season,episodeNumber:e.number,releaseDate:EN(e)}),AN=(e,t)=>{if(t==null)return;let n;for(let r of e)r.season!==t||!r.airdate||(!n||r.airdate<n)&&(n=r.airdate);return n},jN=e=>{let t=new Map;for(let n of e)n.season!=null&&t.set(n.season,(t.get(n.season)??0)+1);return[...t].map(([t,n])=>({season:{seasonNumber:t},seasonNumber:t,episodeCount:n,premiere:AN(e,t),episodeTitles:e.filter(e=>e.season===t).map(e=>e.name??``)}))},MN=(e,t,n)=>{let r=ON(e,n,DN(e),AN(t,n));return r.episodes=(n==null?t:t.filter(e=>e.season===n)).map(e=>kN(e,r.uri)),r.episodeCount=r.episodes.length,r},NN=async(e,t,n,r)=>{let i=await TN(`/shows/${t}?embed=episodes`,r);if(!i)return;let a=i._embedded?.episodes??[],o=jN(a),s=n??(o.length?await UT(e,r,e=>ZD({titles:(e?.titles??[]).map(e=>e.title),startDate:e?.startDate,episodeCount:e?.episodeCount??void 0},o)?.season.seasonNumber):void 0);if(!(s==null&&o.length>1))return MN(i,a,s)},PN=async(e,t)=>{let n=await TN(`/shows/${e.showId}?embed=episodes`,t);if(!n)return;let r=n._embedded?.episodes??[],i=ZD(e,jN(r));return i?MN(n,r,i.season.seasonNumber):void 0},FN=async(e,t)=>(await TN(`/search/shows?q=${encodeURIComponent(e)}`,t)??[]).map(e=>ON(e.show,void 0,DN(e.show))),IN={Subscription:{similarMedia:{subscribe:async function*(e,{input:t},n){if(!t?.showId)return yield{similarMedia:null};yield{similarMedia:await PN(t,n)??null}}},media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,bN);if(!r)return yield{media:null};let{showId:i,seasonNumber:a}=$w(r.id);yield{media:await NN(t,i,a,n)??null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await FN(t,n)}}}}},Media:{episodes:async(e,t,n)=>{if(e.origin!==`tvmaze`)return e.episodes??[];if(e.episodes?.length)return e.episodes;let{showId:r,seasonNumber:i}=$w(e.id),a=await TN(`/shows/${r}/episodes`,n);return(i==null?a??[]:(a??[]).filter(e=>e.season===i)).map(t=>kN(t,e.uri))}}},LN=({season:e,year:t,page:n})=>`/anime?filter%5Bseason%5D=${e}&filter%5BseasonYear%5D=${t}&page%5Bsize%5D=20&page%5Bnumber%5D=${n}&sort=-userCount%2CcreatedAt&include=mappings`,RN=(e=8)=>Array.from({length:e},(e,t)=>t+1),zN=/\/(series|title|watch|shows?)\/([^/?#]+)/,BN=[[/crunchyroll\.com/,`cr`],[/netflix\.com/,`nf`],[/hulu\.com/,`hulu`],[/disneyplus\.com/,`disney`],[/(primevideo|amazon)\./,`amazon`],[/(hbomax|max)\.com/,`hbo`]],VN=e=>{let t=[];for(let n of e){if(!n)continue;let e;try{e=new URL(n)}catch{continue}let r=BN.find(([t])=>t.test(e.hostname))?.[1];if(!r)continue;let i=zN.exec(e.pathname);i&&t.push({origin:r,id:i[2],url:n,scope:i[1]})}return t},HN=new Set([`nf:title`,`nf:watch`]),UN=({origin:e,scope:t})=>HN.has(`${e}:${t}`);var WN=c({categories:()=>JN,color:()=>QN,icon:()=>KN,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>YN,official:()=>!1,origin:()=>XN,originUrl:()=>qN,resolvers:()=>pP,supportedUris:()=>ZN});const GN=.3,KN=`https://kitsu.io/favicon.ico`,qN=`https://kitsu.io`,JN=[`ANIME`,`SERIES`,`MOVIE`],YN=`Kitsu`,XN=`kitsu`,ZN=[`kitsu`],QN=`#f75239`,$N=(e,t)=>t.fetch(`https://kitsu.io/api/edge${e}`).then(e=>e.json()).catch(()=>void 0),eP=e=>{let t=[];for(let n of e){let e=n.externalId;e&&(n.externalSite===`anilist/anime`?t.push(H({origin:`anilist`,id:e,url:`https://anilist.co/anime/${e}`})):n.externalSite===`myanimelist/anime`&&t.push(H({origin:`mal`,id:e,url:`https://myanimelist.net/anime/${e}`})))}return t},tP=(e,t)=>{let n=VN(e.map(e=>e.url)),r=({origin:e,id:t,url:n})=>iT(H({origin:e,id:t,url:n}));return t.subtype===`movie`?n.map(e=>UN(e)?rT(H({origin:e.origin,id:e.id,url:e.url})):r(e)):n.map(r)},nP=e=>new Map((e.included??[]).map(e=>[e.id,e.attributes])),rP=(e,t)=>(e.relationships?.mappings?.data??[]).map(e=>t.get(e.id)).filter(e=>!!e),iP=e=>{let t=e.titles??{},n=[[t.en,`en`],[e.canonicalTitle??void 0,`en`],[t.ja_jp,`ja`]],r=[],i=new Set;for(let[e,t]of n)e&&!i.has(e)&&(i.add(e),r.push({language:t,title:e,score:GN}));return r},aP=(e,t=[])=>{let n=e.attributes;return H({origin:XN,id:e.id,url:`https://kitsu.io/anime/${e.id}`,handles:t,score:GN,categories:n.subtype===`movie`?[`ANIME`,`MOVIE`]:[`ANIME`,`SERIES`],type:n.subtype===`TV`?FS.Tv:n.subtype===`movie`?FS.Movie:n.subtype===`special`?FS.Special:n.subtype===`OVA`?FS.Ova:n.subtype===`ONA`?FS.Ona:void 0,titles:iP(n),...uT(n.synopsis??void 0,GN),covers:dT(n.posterImage?.original??n.posterImage?.large??n.posterImage?.medium,GN),banners:dT(n.coverImage?.original??n.coverImage?.large,GN),startDate:n.startDate||void 0,endDate:n.endDate||void 0,episodeCount:n.episodeCount??void 0,popularity:n.userCount??void 0,status:n.status===`current`?PS.Releasing:n.status===`upcoming`?PS.NotYetReleased:n.status===`finished`?PS.Finished:void 0,trailers:n.youtubeVideoId?[{uri:`yt:${n.youtubeVideoId}`,origin:`yt`,id:n.youtubeVideoId,url:`https://www.youtube.com/watch?v=${n.youtubeVideoId}`,language:`en`}]:[],averageScore:nE(n.averageRating,100)})},oP=(e,t)=>{let n=e.attributes;return oT({origin:XN,id:e.id,mediaUri:t,score:GN,titles:n.canonicalTitle?[{language:`en`,title:n.canonicalTitle,score:GN}]:[],...uT(n.synopsis??void 0,GN),thumbnails:dT(n.thumbnail?.original??n.thumbnail?.large??n.thumbnail?.medium,GN),seasonNumber:n.seasonNumber??void 0,episodeNumber:n.number??void 0})},sP=async(e,t,n)=>{let r=[];for(let i=0;i<2e3;i+=20){let a=await $N(`/anime/${e}/episodes?page%5Blimit%5D=20&page%5Boffset%5D=${i}&sort=number`,n),o=Array.isArray(a?.data)?a.data:[];if(r.push(...o.map(e=>oP(e,t))),o.length<20)break}return r},cP=async(e,t)=>{let[n,r]=await Promise.all([$N(`/anime/${e}?include=mappings`,t),$N(`/anime/${e}/streaming-links`,t)]),i=n?.data,a=Array.isArray(i)?i[0]:i;if(!a)return;let o=Array.isArray(r?.data)?r.data:[],s=[...eP(rP(a,nP(n??{}))),...tP(o.map(e=>e.attributes),a.attributes)],c=aP(a,s);return c.episodes=await sP(e,c.uri,t),c.episodeCount=c.episodes.length,c},lP=async(e,t)=>{let n=await $N(`/anime?filter%5Btext%5D=${encodeURIComponent(e)}&include=mappings&page%5Blimit%5D=10`,t),r=Array.isArray(n?.data)?n.data:[],i=nP(n??{});return r.map(e=>aP(e,eP(rP(e,i))))},uP=async({season:e,year:t,page:n},r)=>{try{let i=await $N(LN({season:e,year:t,page:n}),r),a=Array.isArray(i?.data)?i.data:[],o=nP(i??{});return a.map(n=>({...aP(n,eP(rP(n,o))),season:Bw(e),seasonYear:t}))}catch(e){return console.error(`Kitsu season page ${n} failed`,e),[]}},dP=async(e,{season:t,year:n}=Rw())=>{let r=await Promise.all(RN().map(r=>uP({season:t,year:n,page:r},e))),i=new Map;for(let e of r.flat())i.has(e.uri)||i.set(e.uri,e);return[...i.values()]},fP=({season:e,seasonYear:t})=>{let n=e?Vw(e):void 0;return n&&t?{season:n,year:t}:void 0},pP={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,XN);yield{media:r?await cP(r.id,n)??null:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:t},n){let{search:r,status:i,season:a,seasonYear:o}=t,s=fP(t);if(s)return yield{mediaPage:{nodes:await dP(n,s)}};if(i===`RELEASING`&&!a&&!o)return yield{mediaPage:{nodes:await dP(n)}};if(!r)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await lP(r,n)}}}}},Media:{episodes:async(e,t,n)=>e.origin===`kitsu`?e.episodes?.length?e.episodes:sP(e.id,e.uri,n):e.episodes??[]}};var mP=c({categories:()=>vP,color:()=>SP,icon:()=>gP,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>yP,official:()=>!1,origin:()=>bP,originUrl:()=>_P,resolvers:()=>AP,supportedUris:()=>xP});const hP=.3,gP=`https://www.omdbapi.com/favicon.ico`,_P=`https://www.omdbapi.com`,vP=[`SERIES`,`MOVIE`],yP=`OMDb`,bP=`omdb`,xP=[`omdb`],SP=`#f5c518`,CP=e=>e&&e!==`N/A`?e:void 0,wP=(e,t)=>{let n=t.key(bP);return n?t.fetch(`https://www.omdbapi.com/?apikey=${n}&${e}`).then(e=>e.json()).catch(()=>void 0):Promise.resolve(void 0)},TP=e=>{let t=e.imdbID;if(!t)return;let n=CP(e.imdbRating),r=CP(e.Year)?.match(/\d{4}/)?.[0],i=e.Type===`movie`?`RUN`:`CONTAINER`;return H({origin:bP,id:t,url:`https://www.imdb.com/title/${t}`,scope:i,handles:[H({origin:`imdb`,id:t,url:`https://www.imdb.com/title/${t}`,scope:i})],categories:e.Type===`movie`?[`MOVIE`]:[`SERIES`],score:hP,titles:e.Title?[{language:`en`,title:e.Title,score:hP}]:[],...uT(CP(e.Plot),hP),covers:dT(CP(e.Poster),hP),averageScore:nE(n,10),startDate:r?`${r}-01-01`:void 0})},EP=(e,t,n,r)=>oT({origin:bP,id:e.imdbID??`${n}-s${t}e${e.Episode}`,mediaUri:r,score:hP,titles:CP(e.Title)?[{language:`en`,title:e.Title,score:hP}]:[],seasonNumber:t,episodeNumber:e.Episode?Number(e.Episode):void 0}),DP=async(e,t,n,r)=>{let i=Array.from({length:t},(e,t)=>t+1);return(await Promise.all(i.map(t=>wP(`i=${e}&Season=${t}`,r).then(r=>(r?.Episodes??[]).map(r=>EP(r,t,e,n)))))).flat()},OP=async(e,t)=>{let n=await wP(`i=${e}&plot=full`,t);if(!n||n.Response===`False`)return;let r=TP(n);if(!r)return;let i=CP(n.totalSeasons);return i&&Number(i)===1?(r.episodes=await DP(e,1,r.uri,t),r.episodeCount=r.episodes.length):i?r.episodeCount=void 0:cT(r)&&(r.episodes=[sT(r)],r.episodeCount=1),r},kP=async(e,t)=>((await wP(`s=${encodeURIComponent(e)}`,t))?.Search??[]).map(TP).filter(e=>!!e),AP={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,bP);yield{media:r?await OP(r.id,n)??null:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await kP(t,n)}}}}},Media:{episodes:async(e,t,n)=>{if(e.origin!==`omdb`)return e.episodes??[];if(e.episodes?.length)return e.episodes;if(cT(e))return[sT(e)];let r=await wP(`i=${e.id}&plot=short`,n),i=CP(r?.totalSeasons);return i?DP(e.id,Number(i),e.uri,n):[]}}};var jP=c({categories:()=>FP,color:()=>zP,icon:()=>NP,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>IP,official:()=>!1,origin:()=>LP,originUrl:()=>PP,resolvers:()=>XP,supportedUris:()=>RP});const MP=.3,NP=`https://walter.trakt.tv/hotlink-ok/public/favicon.ico`,PP=`https://trakt.tv`,FP=[`SERIES`],IP=`Trakt`,LP=`trakt`,RP=[`trakt`],zP=`#ed1c24`,BP=(e,t)=>{let n=t.key(LP);return n?t.fetch(`https://api.trakt.tv${e}`,{headers:{"trakt-api-key":n,"trakt-api-version":`2`,"Content-Type":`application/json`}}).then(e=>e.json()).catch(()=>void 0):Promise.resolve(void 0)},VP=/^\d{4}-\d{2}-\d{2}$/,HP=e=>{if(!e)return;if(VP.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()},UP=e=>e?.slug??(e?.trakt===void 0?void 0:String(e.trakt)),WP=e=>{let t=[];return e?.imdb&&t.push(H({origin:`imdb`,id:e.imdb,url:`https://www.imdb.com/title/${e.imdb}`,scope:`CONTAINER`})),t},GP=e=>{let t=UP(e.ids);if(!t)return;let n=e.rating;return H({origin:LP,id:t,url:`https://trakt.tv/shows/${t}`,scope:`CONTAINER`,handles:WP(e.ids),categories:[`SERIES`],score:MP,titles:e.title?[{language:`en`,title:e.title,score:MP}]:[],...uT(e.overview,MP),startDate:e.first_aired?new Date(e.first_aired).toISOString():void 0,averageScore:n===void 0?void 0:Math.round(n*10)})},KP=(e,t,n,r)=>{let i=e.number;return oT({origin:LP,id:e.ids?.trakt===void 0?`${n}-s${t}e${i??0}`:String(e.ids.trakt),mediaUri:r,score:MP,titles:e.title?[{language:`en`,title:e.title,score:MP}]:[],...uT(e.overview,MP),seasonNumber:t,episodeNumber:i,releaseDate:HP(e.first_aired)})},qP=async(e,t,n)=>{let r=await BP(`/shows/${encodeURIComponent(e)}/seasons?extended=episodes,full`,n);return r?r.filter(e=>(e.number??0)>0).flatMap(n=>(n.episodes??[]).map(r=>KP(r,n.number??0,e,t))):[]},JP=async(e,t)=>{let n=await BP(`/shows/${encodeURIComponent(e)}?extended=full`,t);if(!n)return;let r=GP(n);if(!r)return;let i=await qP(e,r.uri,t);return new Set(i.map(e=>e.seasonNumber??0)).size<=1&&(r.episodes=i,r.episodeCount=i.length),r},YP=async(e,t)=>(await BP(`/search/show?query=${encodeURIComponent(e)}`,t)??[]).map(e=>e.show?GP(e.show):void 0).filter(e=>!!e),XP={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,LP);yield{media:r?await JP(r.id,n)??null:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await YP(t,n)}}}}},Media:{episodes:async(e,t,n)=>e.origin===`trakt`?e.episodes?.length?e.episodes:qP(e.id,e.uri,n):e.episodes??[]}};var ZP=c({categories:()=>nF,color:()=>oF,icon:()=>eF,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>rF,official:()=>!1,origin:()=>iF,originUrl:()=>tF,resolvers:()=>AF,supportedUris:()=>aF});const QP=.3,$P=`https://simkl.in`,eF=`https://simkl.com/favicon.ico`,tF=`https://simkl.com`,nF=[`ANIME`,`SERIES`,`MOVIE`],rF=`Simkl`,iF=`simkl`,aF=[`simkl`],oF=`#0b0f10`,sF=(e,t)=>{let n=t.key(iF);return n?t.fetch(`https://api.simkl.com${e}`,{headers:{"simkl-api-key":n}}).then(e=>e.json()).catch(()=>void 0):Promise.resolve(void 0)},cF=e=>e?`${$P}/posters/${e}_m.jpg`:void 0,lF=e=>e?`${$P}/fanart/${e}_w.jpg`:void 0,uF=e=>e?`${$P}/episodes/${e}_w.jpg`:void 0,dF=e=>e===`tv`?`/tv`:e===`anime`?`/anime`:`/movies`,fF=e=>e===`tv`?`/tv/episodes`:`/anime/episodes`,pF=e=>e===`anime`?`anime`:e===`movies`?`movies`:`tv`,mF=e=>e===`movies`?[`MOVIE`]:e===`anime`?[`ANIME`,`SERIES`]:[`SERIES`],hF=e=>e===`tv`?`CONTAINER`:`RUN`,gF=e=>e===`movies`?`RUN`:`CONTAINER`,_F=(e,t)=>{if(!e)return[];let n=[];return e.imdb&&n.push(H({origin:`imdb`,id:e.imdb,url:`https://www.imdb.com/title/${e.imdb}`,scope:gF(t)})),e.mal&&n.push(H({origin:`mal`,id:e.mal,url:`https://myanimelist.net/anime/${e.mal}`})),e.anilist&&n.push(H({origin:`anilist`,id:e.anilist,url:`https://anilist.co/anime/${e.anilist}`})),e.kitsu&&n.push(H({origin:`kitsu`,id:e.kitsu,url:`https://kitsu.io/anime/${e.kitsu}`})),n},vF=/^\d{4}-\d{2}-\d{2}$/,yF=e=>{if(!e)return;if(vF.test(e))return e;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toISOString()},bF=e=>e?.simkl?.rating??e?.imdb?.rating??e?.mal?.rating,xF=(e,t)=>{let n=[],r=new Set;for(let i of[e,t??void 0])i&&!r.has(i)&&(r.add(i),n.push({language:`en`,title:i,score:QP}));return n},SF=e=>{let t=e.ids?.simkl??e.ids?.simkl_id;if(t===void 0)return;let n=pF(e.endpoint_type);return H({origin:iF,id:String(t),url:`https://simkl.com/${n}/${t}`,scope:hF(n),handles:_F(e.ids,n),categories:mF(n),score:QP,titles:xF(e.title),covers:dT(cF(e.poster),QP),averageScore:nE(bF(e.ratings),10)})},CF=(e,t,n)=>{if(e.title)return H({origin:iF,id:t,url:`https://simkl.com/${n}/${t}`,scope:hF(n),handles:_F(e.ids,n),categories:mF(n),score:QP,titles:xF(e.title,e.en_title),...uT(e.overview,QP),covers:dT(cF(e.poster),QP),banners:dT(lF(e.fanart),QP),startDate:e.first_aired||void 0,averageScore:nE(bF(e.ratings),10)})},wF=(e,t,n,r)=>{let i=e.season??1,a=e.episode;return oT({origin:iF,id:a===void 0?`${t}-i${r}`:`${t}-s${i}e${a}`,mediaUri:n,score:QP,titles:e.title?[{language:`en`,title:e.title,score:QP}]:[],...uT(e.description??void 0,QP),thumbnails:dT(uF(e.img),QP),seasonNumber:e.season??void 0,episodeNumber:a??void 0,releaseDate:yF(e.date)})},TF=async(e,t,n,r)=>{if(t===`movies`)return[];let i=await sF(`${fF(t)}/${e}?extended=full`,r);return(Array.isArray(i)?i:[]).filter(e=>e.type!==`special`||e.episode!==void 0||!!e.title).map((t,r)=>wF(t,e,n,r))},EF=async(e,t)=>{for(let n of[`tv`,`anime`,`movies`]){let r=await sF(`${dF(n)}/${e}?extended=full`,t),i=r?CF(r,e,n):void 0;if(i)return cT(i)?(i.episodes=[sT(i)],i.episodeCount=1,i):(i.episodes=await TF(e,n,i.uri,t),i.episodeCount=i.episodes.length,i)}},DF=e=>e===`movies`?`movie`:e,OF=async(e,t,n)=>{let r=await sF(`/search/${DF(t)}?q=${encodeURIComponent(e)}&extended=full&limit=10`,n);return(Array.isArray(r)?r:[]).map(SF).filter(e=>!!e)},kF=async(e,t)=>{let n=await Promise.all([`tv`,`anime`,`movies`].map(n=>OF(e,n,t))),r=[],i=new Set;for(let e of n.flat())i.has(e.id)||(i.add(e.id),r.push(e));return r},AF={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,iF);yield{media:r?await EF(r.id,n)??null:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await kF(t,n)}}}}},Media:{episodes:async(e,t,n)=>e.origin===`simkl`?e.episodes?.length?e.episodes:cT(e)?[sT(e)]:(await EF(e.id,n))?.episodes??[]:e.episodes??[]}};var jF=c({categories:()=>IF,color:()=>BF,icon:()=>PF,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>LF,official:()=>!1,origin:()=>RF,originUrl:()=>FF,resolvers:()=>tI,supportedUris:()=>zF});const MF=.3,NF=`https://api4.thetvdb.com/v4`,PF=`https://www.thetvdb.com/images/icon.png`,FF=`https://www.thetvdb.com`,IF=[`SERIES`],LF=`TheTVDB`,RF=`tvdb`,zF=[`tvdb`],BF=`#6cd591`,VF=e=>e?e.startsWith(`http`)?e:`https://artworks.thetvdb.com${e.startsWith(`/`)?``:`/`}${e}`:void 0,HF={imdb:`imdb`,themoviedb:`tmdb`,tmdb:`tmdb`},UF=(e,t)=>e===`imdb`?`https://www.imdb.com/title/${t}`:e===`tmdb`?`https://www.themoviedb.org/tv/${t}`:void 0,WF=e=>{let t=[];for(let n of e??[]){let e=n.id,r=n.sourceName?HF[n.sourceName.toLowerCase()]:void 0,i=e&&r?UF(r,e):void 0;e&&r&&i&&t.push(H({origin:r,id:e,url:i,scope:`CONTAINER`}))}return t};let GF;const KF=async e=>{let t=e.key(RF);if(!t)return;let n=t.indexOf(`:`),r=n===-1?t:t.slice(0,n),i=n===-1?void 0:t.slice(n+1),a=JSON.stringify(i?{apikey:r,pin:i}:{apikey:r});return(await e.fetch(`${NF}/login`,{method:`POST`,headers:{"content-type":`application/json`},body:a}).then(e=>e.json()).catch(()=>void 0))?.data?.token},qF=async e=>(GF||=await KF(e),GF),JF=async(e,t)=>{if(!t.key(`tvdb`))return;let n=await qF(t);if(!n)return;let r=n=>t.fetch(`${NF}${e}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r(n).catch(()=>void 0);if(i?.status===401){if(GF=await KF(t),!GF)return;i=await r(GF).catch(()=>void 0)}if(!(!i||!i.ok))return i.json().then(e=>e).catch(()=>void 0)},YF=e=>{let t=e.tvdb_id;if(t)return H({origin:RF,id:t,url:`https://www.thetvdb.com/series/${t}`,scope:`CONTAINER`,handles:WF(e.remote_ids),categories:[`SERIES`],score:MF,titles:e.name?[{language:`en`,title:e.name,score:MF}]:[],...uT(e.overview,MF),covers:dT(VF(e.image_url),MF),startDate:e.year?`${e.year}-01-01`:void 0})},XF=e=>{let t=e.id==null?void 0:String(e.id);if(t)return H({origin:RF,id:t,url:`https://www.thetvdb.com/series/${t}`,scope:`CONTAINER`,handles:WF(e.remoteIds),categories:[`SERIES`],score:MF,titles:e.name?[{language:`en`,title:e.name,score:MF}]:[],...uT(e.overview,MF),covers:dT(VF(e.image),MF),startDate:e.firstAired||void 0})},ZF=(e,t,n)=>oT({origin:RF,id:e.id==null?`${t}-s${e.seasonNumber??0}e${e.number??0}`:String(e.id),mediaUri:n,score:MF,titles:e.name?[{language:`en`,title:e.name,score:MF}]:[],...uT(e.overview,MF),thumbnails:dT(VF(e.image),MF),seasonNumber:e.seasonNumber,episodeNumber:e.number,releaseDate:e.aired||void 0}),QF=async(e,t,n)=>{let r=[],i=0;for(;i<50;){let a=await JF(`/series/${e}/episodes/default?page=${i}`,n),o=a?.data?.episodes??[];for(let n of o)r.push(ZF(n,e,t));if(!a?.links?.next||o.length===0)break;i+=1}return r},$F=async(e,t)=>{let n=await JF(`/series/${e}/extended`,t);if(!n?.data)return;let r=XF(n.data);if(!r)return;let i=await QF(e,r.uri,t);return new Set(i.map(e=>e.seasonNumber??0)).size<=1&&(r.episodes=i,r.episodeCount=i.length),r},eI=async(e,t)=>((await JF(`/search?query=${encodeURIComponent(e)}&type=series`,t))?.data??[]).map(YF).filter(e=>!!e),tI={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,RF);yield{media:r?await $F(r.id,n)??null:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await eI(t,n)}}}}},Media:{episodes:async(e,t,n)=>e.origin===`tvdb`?e.episodes?.length?e.episodes:QF(e.id,e.uri,n):e.episodes??[]}},nI=`offline`,rI=.2,iI=e=>GT(e.startsWith(`http`)?e:`https://cdn.myanimelist.net/images/anime/${e}`),aI=({season:e,year:t})=>`${t}-${e.toUpperCase()}`,oI=/^(\d{4})-([A-Z]+)$/,sI=e=>{let t=oI.exec(e),n=zw.find(e=>e===t?.[2]);return t&&n?{season:n,year:Number(t[1])}:void 0},cI={TV:FS.Tv,MOVIE:FS.Movie,OVA:FS.Ova,ONA:FS.Ona,SPECIAL:FS.Special},lI=e=>e.ml?`mal-${e.ml}`:e.al?`anilist-${e.al}`:e.ku?`kitsu-${e.ku}`:void 0,uI=e=>{let t=[];return e.ml&&t.push(H({origin:`mal`,id:String(e.ml),url:`https://myanimelist.net/anime/${e.ml}`})),e.al&&t.push(H({origin:`anilist`,id:String(e.al),url:`https://anilist.co/anime/${e.al}`})),e.ku&&t.push(H({origin:`kitsu`,id:String(e.ku),url:`https://kitsu.app/anime/${e.ku}`})),t},dI=(e,t)=>{let n=lI(e);if(!n)return;let r=cI[e.ty],i=t?sI(t):void 0;return H({origin:nI,id:n,handles:uI(e),score:rI,season:i?.season??null,seasonYear:i?.year??null,categories:r===FS.Movie?[`ANIME`,`MOVIE`]:[`ANIME`,`SERIES`],type:r,titles:[{language:`en`,title:e.t,score:rI}],covers:e.p?[{url:iI(e.p),score:rI}]:[],episodeCount:e.ep||void 0,popularity:e.pop||void 0,...e.sy?{descriptions:[{language:`en`,description:e.sy,score:rI}],shortDescriptions:[{language:`en`,shortDescription:e.sy,score:rI}]}:{},trailers:e.tr?[{uri:`yt:${e.tr}`,origin:`yt`,id:e.tr,url:`https://www.youtube.com/watch?v=${e.tr}`,language:`en`,...e.th?{thumbnail:e.th}:{}}]:[],averageScore:e.sc?Math.round(e.sc*10):void 0})},fI=(e,t)=>e.map(e=>dI(e,t)).filter(e=>!!e),pI=[`mal`,`anilist`,`kitsu`,`anidb`],mI=e=>{let t={mal:new Map,anilist:new Map,kitsu:new Map,anidb:new Map},n=[],r=0;for(let i=0;i<e.mal.length;i++){let a=e.mal[i],o=a?r+=a:0;n.push(o),o&&t.mal.set(o,i);for(let n of[`anilist`,`kitsu`,`anidb`]){let r=e[n][i];r&&t[n].set(r,i)}}let i=t=>({mal:n[t]??0,anilist:e.anilist[t]??0,kitsu:e.kitsu[t]??0,anidb:e.anidb[t]??0});return{size:n.length,lookup:(e,n)=>{let r=t[e]?.get(n);return r===void 0?void 0:i(r)}}},hI=e=>e.mal?`mal-${e.mal}`:e.anilist?`anilist-${e.anilist}`:e.kitsu?`kitsu-${e.kitsu}`:e.anidb?`anidb-${e.anidb}`:void 0,gI=/^([a-z]+)-(\d+)$/,_I=(e,t)=>{let n=[],r=new Set;for(let i of e){let[e,a]=i.origin===t?gI.exec(i.id)?.slice(1,3)??[]:[i.origin,i.id];if(!e||!a||!pI.includes(e))continue;let o=Number(a);if(!Number.isInteger(o)||o<=0)continue;let s=`${e}:${o}`;r.has(s)||(r.add(s),n.push({origin:e,id:o}))}return n},vI=async e=>{let t=await e.arrayBuffer();try{let e=new Response(t).body;if(!e)throw Error(`the response carried no body to decompress`);return await new Response(e.pipeThrough(new DecompressionStream(`gzip`))).text()}catch{return new TextDecoder().decode(t)}},yI=async(e,t)=>{let n=await e(dw(t));if(!n.ok)throw Error(`${t} answered ${n.status}`);return JSON.parse(await vI(n))},bI=async(e,t,n)=>{let r,i=new Promise(e=>{r=setTimeout(()=>e(void 0),t)});try{return await Promise.race([e,i])}catch(e){console.warn(`offline: ${n} could not be read, the bundled data still answers`,e);return}finally{clearTimeout(r)}};let xI,SI;const CI=e=>xI??=bI(yI(e,lw),1e4,lw).then(e=>{if(e!==void 0){if(Nw(e))return e;console.warn(`offline: ${lw} is not a seed index, the bundled data still answers`)}}),wI=(e,t)=>SI??=bI(yI(e,uw),15e3,uw).then(e=>{if(e!==void 0){if(Iw(e,t))return e;console.warn(`offline: ${uw} does not belong to this index, the index still answers`)}}),TI=new WeakMap,EI=e=>{let t=TI.get(e);if(t)return t;let n=new Map;for(let t of e.runs){n.set(`${nI}:${t.key}`,t);for(let e of t.identity)n.set(e.uri,t)}return TI.set(e,n),n},DI=(e,t)=>{let n=EI(e);for(let e of t){let t=n.get(`${e.origin}:${e.id}`);if(t)return t}},OI=e=>H({origin:e.origin,id:e.id}),kI=e=>({node:OI(e),relation:`PART_OF`}),AI=(e,t)=>oT({origin:nI,id:`${e.key}-${t.number}`,mediaUri:`${nI}:${e.key}`,url:t.urls[0]?.url,score:rI,episodeNumber:t.number,titles:t.titles.map(({language:e,title:t})=>({language:e,title:t,score:rI})),thumbnails:t.thumbnails.map(({url:e,language:t})=>({url:e,language:t,score:rI})),releaseDate:t.releaseDate,seasonNumber:t.seasonNumber,absoluteEpisodeNumber:t.absoluteEpisodeNumber,runtime:t.runtime}),jI=(e,t)=>{let n=e.season?sI(e.season):void 0;return H({origin:nI,id:e.key,score:rI,season:n?.season??null,seasonYear:n?.year??null,handles:[...e.identity.map(e=>rT(OI(e))),...e.containers.map(kI)],titles:e.titles.map(({language:e,title:t})=>({language:e,title:t,score:rI})),covers:e.covers.map(({url:e,language:t})=>({url:e,language:t,score:rI})),banners:e.banners.map(({url:e,language:t})=>({url:e,language:t,score:rI})),type:e.type,categories:e.categories,episodeCount:e.episodeCount,averageScore:e.averageScore,popularity:e.popularity,isAdult:e.isAdult,episodes:(t??[]).map(t=>AI(e,t))})},MI=(e,t)=>{let n=new Map(e.runs.map(e=>[e.key,e]));return(e.seasons[t]??[]).map(e=>n.get(e)).filter(e=>!!e).map(e=>jI(e))};var NI=c({categories:()=>FI,color:()=>zI,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>II,official:()=>!1,origin:()=>LI,originUrl:()=>PI,resolvers:()=>YI,supportedUris:()=>RI});const PI=`https://github.com/manami-project/anime-offline-database`,FI=[`ANIME`,`SERIES`,`MOVIE`],II=`Offline database`,LI=nI,RI=[`offline`,...pI],zI=`#2b6cb0`;let BI,VI;const HI=()=>BI??=import(`./anime-seasons-CVM0BQGM.js`).then(e=>e.default).catch(e=>(console.error(`offline: the bundled season data could not be loaded`,e),{tag:`unavailable`,updated:``,seasons:{}})),UI=()=>VI??=import(`./anime-index-Jbe1K3rX.js`).then(e=>mI(e.default)).catch(e=>(console.error(`offline: the bundled id index could not be loaded`,e),mI({mal:[],anilist:[],kitsu:[],anidb:[]}))),WI=async e=>{let t=await HI(),n=t.seasons[e];return n?fI(n,e):(console.warn(`offline: no bundled data for ${e}; the dump (${t.tag}) holds ${Object.keys(t.seasons).join(`, `)||`nothing`}`),[])},GI=e=>{if(qS(e))return ZS(e)?.handleUrisValues??[];if(HS(e)){let t=RS(e);return t?[t]:[]}return[]},KI=e=>{let t=hI(e);if(!t)return;let n=[];if(e.mal&&n.push(H({origin:`mal`,id:String(e.mal),url:`https://myanimelist.net/anime/${e.mal}`})),e.anilist&&n.push(H({origin:`anilist`,id:String(e.anilist),url:`https://anilist.co/anime/${e.anilist}`})),e.kitsu&&n.push(H({origin:`kitsu`,id:String(e.kitsu),url:`https://kitsu.app/anime/${e.kitsu}`})),e.anidb&&n.push(H({origin:`anidb`,id:String(e.anidb),url:`https://anidb.net/anime/${e.anidb}`})),!(n.length<2))return H({origin:LI,id:t,handles:n,score:rI})},qI=async e=>{let t=await HI();for(let[n,r]of Object.entries(t.seasons)){let t=fI(r,n).find(t=>t.id===e);if(t)return t}},JI=async e=>{let t=GI(e);if(!t.length)return null;let n=t.find(e=>e.origin===LI);if(n){let e=await qI(n.id);if(e)return e}let r=_I(t,LI);if(!r.length)return null;let i=await UI();for(let e of r){let t=i.lookup(e.origin,e.id);if(!t)continue;let n=KI(t);if(n)return await qI(n.id)??n}return null},YI={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t)return yield{media:null};yield{media:await JI(t)};let r=await CI(n.fetch);if(!r)return;let i=DI(r,GI(t));i&&(yield{media:jI(i,(await wI(n.fetch,r))?.episodes[i.key])})}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{status:t,season:n,seasonYear:r}},i){let a=n&&r?aI({season:n,year:r}):void 0;if(!a&&(n||r||t!==`RELEASING`))return yield{mediaPage:{nodes:[]}};let o=a??aI(Rw());yield{mediaPage:{nodes:await WI(o)}};let s=await CI(i.fetch);if(!s)return;let c=MI(s,o);c.length&&(yield{mediaPage:{nodes:c}})}}}};var XI=c({categories:()=>$I,color:()=>rL,icon:()=>ZI,isApiOnly:()=>!1,metadataOnly:()=>!0,name:()=>eL,official:()=>!1,origin:()=>tL,originUrl:()=>QI,resolvers:()=>iL,supportedUris:()=>nL});const ZI=`https://www.imdb.com/favicon.ico`,QI=`https://www.imdb.com`,$I=[`SERIES`,`MOVIE`],eL=`IMDb`,tL=`imdb`,nL=[`imdb`],rL=`#f5c518`,iL={Subscription:{media:{subscribe:async function*(){yield{media:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(){yield{mediaPage:{nodes:[]}}}}}};var aL=c({categories:()=>lL,color:()=>pL,icon:()=>sL,isApiOnly:()=>!0,metadataOnly:()=>!0,name:()=>uL,official:()=>!1,origin:()=>dL,originUrl:()=>cL,resolvers:()=>DL,supportedUris:()=>fL});const oL=.25,sL=`https://api.watchmode.com/favicon.ico`,cL=`https://www.watchmode.com`,lL=[`SERIES`,`MOVIE`],uL=`Watchmode`,dL=`watchmode`,fL=[`watchmode`],pL=`#1fb6ff`,mL=(e,t)=>{let n=t.key(dL);if(!n)return Promise.resolve(void 0);let r=e.includes(`?`)?`&`:`?`;return t.fetch(`https://api.watchmode.com/v1${e}${r}apiKey=${n}`).then(e=>e.json()).catch(()=>void 0)},hL=[{match:e=>e.endsWith(`crunchyroll.com`),origin:`cr`},{match:e=>e.endsWith(`netflix.com`),origin:`nf`},{match:e=>e.endsWith(`hulu.com`),origin:`hulu`},{match:e=>e.endsWith(`disneyplus.com`),origin:`disney`},{match:e=>e.endsWith(`primevideo.com`)||e.includes(`amazon.`),origin:`amazon`},{match:e=>e.endsWith(`max.com`)||e.endsWith(`hbomax.com`),origin:`hbo`}],gL=e=>hL.find(t=>t.match(e))?.origin,_L=(e,t)=>{let n=EA(e);return n?wA(t,n):void 0},vL=(e,t)=>{let n=e.web_url;if(!n)return;let r;try{r=new URL(n).hostname.replace(/^www\./,``)}catch{return}let i=gL(r);if(!i)return;let a=_L(n,i);if(!a)return;let o=H({origin:i,id:a,url:n}),s=VN([n])[0];return t&&s?.origin===i&&s.id===a&&UN(s)?rT(o):iT(o)},yL=e=>{let t=[],n=e.imdb_id;n&&t.push(iT(H({origin:`imdb`,id:n,url:`https://www.imdb.com/title/${n}`})));let r=e.tmdb_id;return r!=null&&e.tmdb_type!==`movie`&&t.push(iT(H({origin:`tmdb`,id:String(r),url:`https://www.themoviedb.org/tv/${r}`}))),t},bL=e=>{let t=new Set,n=[];for(let r of e)t.has(r.node.uri)||(t.add(r.node.uri),n.push(r));return n},xL=e=>e&&(e.includes(`movie`)||e.includes(`short_film`))?[`MOVIE`]:[`SERIES`],SL=e=>xL(e)[0]===`MOVIE`?`RUN`:`CONTAINER`,CL=e=>{let t=e.id;if(t==null)return;let n=String(t);return H({origin:dL,id:n,url:`https://www.watchmode.com/title/${n}/`,handles:yL(e),score:oL,scope:SL(e.type),categories:xL(e.type),titles:e.name?[{language:`en`,title:e.name,score:oL}]:[]})},wL=(e,t)=>{let n=e.id;if(n==null)return;let r=String(n),i=e.user_rating,a=xL(e.type)[0]===`MOVIE`,o=t.map(e=>vL(e,a)).filter(e=>!!e);return H({origin:dL,id:r,url:`https://www.watchmode.com/title/${r}/`,handles:bL([...yL(e),...o]),score:oL,scope:SL(e.type),categories:xL(e.type),titles:e.title?[{language:`en`,title:e.title,score:oL}]:[],...uT(e.plot_overview??void 0,oL),covers:dT(e.poster??void 0,oL),averageScore:i==null?void 0:Math.round(i*10)})},TL=async(e,t)=>{let[n,r]=await Promise.all([mL(`/title/${encodeURIComponent(e)}/details/`,t),mL(`/title/${encodeURIComponent(e)}/sources/`,t)]);if(!n)return;let i=wL(n,Array.isArray(r)?r:[]);return i&&cT(i)&&(i.episodes=[sT(i)],i.episodeCount=1),i},EL=async(e,t)=>((await mL(`/search/?search_field=name&search_value=${encodeURIComponent(e)}`,t))?.title_results??[]).map(CL).filter(e=>!!e),DL={Subscription:{media:{subscribe:async function*(e,{input:{uri:t}},n){if(!t||!(HS(t)||qS(t)))return yield{media:null};let r=LS(t,dL);yield{media:r?await TL(r.id,n)??null:null}}},mediaPage:{resolve:e=>e.mediaPage,subscribe:async function*(e,{input:{search:t}},n){if(!t)return yield{mediaPage:{nodes:[]}};yield{mediaPage:{nodes:await EL(t,n)}}}}},Media:{episodes:async(e,t,n)=>e.origin===`watchmode`?e.episodes?.length?e.episodes:cT(e)?[sT(e)]:[]:e.episodes??[]}};var OL=c({amazon:()=>sM,anilist:()=>PE,anizip:()=>mD,appletv:()=>mj,crunchyroll:()=>sO,disney:()=>Qj,fubo:()=>VM,hbo:()=>PM,hulu:()=>gM,imdb:()=>XI,jikan:()=>rE,justwatch:()=>BA,kitsu:()=>WN,offline:()=>NI,omdb:()=>mP,paramount:()=>zj,peacock:()=>TM,simkl:()=>ZP,tmdb:()=>oee,trakt:()=>jP,tvdb:()=>jF,tvmaze:()=>mN,unogs:()=>yk,watchmode:()=>aL});const kL=e=>{if(typeof e==`object`&&e){if(typeof Object.getPrototypeOf==`function`){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}return Object.prototype.toString.call(e)===`[object Object]`}return!1},AL=(...e)=>e.reduce((e,t)=>{if(Array.isArray(t))throw TypeError(`Arguments provided to ts-deepmerge must be objects, not arrays.`);return Object.keys(t).forEach(n=>{[`__proto__`,`constructor`,`prototype`].includes(n)||(Array.isArray(e[n])&&Array.isArray(t[n])?e[n]=AL.options.mergeArrays?AL.options.uniqueArrayItems?Array.from(new Set(e[n].concat(t[n]))):[...e[n],...t[n]]:t[n]:kL(e[n])&&kL(t[n])?e[n]=AL(e[n],t[n]):e[n]=t[n]===void 0?AL.options.allowUndefinedOverrides?t[n]:e[n]:t[n])}),e},{}),jL={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};AL.options=jL,AL.withOptions=(e,...t)=>{AL.options={...jL,...e};let n=AL(...t);return AL.options=jL,n};const ML=(e,t)=>t.includes(e.origin)||(e.supportedUris??[]).some(e=>t.includes(e)),NL=new Set([408,429,502,503,504,522,524]),PL=15e3,FL=(e,t,n=Date.now())=>{let r=e.headers.get(`retry-after`),i=Number(r),a=r&&Number.isFinite(i)?i*1e3:r?new Date(r).getTime()-n:NaN,o=Number.isFinite(a)&&a>0?a:IL(t);return Math.min(o,PL)},IL=e=>Math.min(1e3*2**e,PL),LL=(e,{wait:t=e=>new Promise(t=>setTimeout(t,e)),now:n=()=>Date.now()}={})=>async(r,i)=>{for(let a=0;;a++){let o;try{o=await e(r,i)}catch(e){if(a>=3)throw e;await t(IL(a));continue}if(!NL.has(o.status)||a>=3)return o;o.body?.cancel().catch(()=>{}),await t(FL(o,a,n()))}},RL=new Set([`https://www.netflix.com`]),zL=e=>{let t=typeof e==`string`?e:e instanceof URL?e.href:typeof e?.url==`string`?e.url:void 0;if(t===void 0)return!1;try{return RL.has(new URL(t).origin)}catch{return!1}},BL=(e,t)=>(n,r)=>zL(n)?t(n,r):e(n,r),VL=Iv({},{transport:globalThis,key:`fetch`}),HL=LL(BL((e,t)=>VL.then(({fetch:n})=>n(e,t)),(e,t)=>globalThis.fetch(e,t)));function UL(){let e=new Map,t=new Map,n=new Map;function r(r){e.has(r)||(e.set(r,r),t.set(r,0),n.set(r,new Set([r])))}function i(t){r(t);let n=t;for(;e.get(n)!==n;)n=e.get(n);let i=t;for(;i!==n;){let t=e.get(i);e.set(i,n),i=t}return n}function a(r,a){let o=i(r),s=i(a);if(o===s)return!1;let c=t.get(o),l=t.get(s),u,d;c<l?(u=s,d=o):c>l?(u=o,d=s):(u=o,d=s,t.set(u,c+1)),e.set(d,u);let f=n.get(u);for(let e of n.get(d))f.add(e);return n.delete(d),!0}function o(t){return e.has(t)?n.get(i(t))??GL:GL}function s(){return n.values()}function c(t){return e.has(t)}return{has:c,find:i,union:a,component:o,allComponents:s}}function WL(){let e=new Map,t=new Map,n=new Map,r=new Map,i=new Map,a=new Map,o=new Map,s=(e,t)=>`${e}\u0000${t}`,c=new Map,l=new Map,u=new Map;function d(e,t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}function f(e){let t=a.get(e);return t||(t=UL(),a.set(e,t)),t}function p(t,n,r){let i=c.get(t),a=new Set(i);if(r?.addLabels)for(let e of r.addLabels)a.add(e);if(r?.removeLabels)for(let e of r.removeLabels)a.delete(e);let o=[];for(let e of a){let t=u.get(e);t&&o.push(t)}if(o.length>1)throw Error(`Node "${t}" has multiple labels with merge functions: cannot resolve which to use`);let s=e.get(t),d=o.length===1&&s!=null?o[0](n,s):n;if(e.set(t,d),i)for(let e of i)a.has(e)||l.get(e)?.delete(t);if(a.size>0){c.set(t,a);for(let e of a)l.has(e)||l.set(e,new Set),l.get(e).add(t)}else c.delete(t)}function m(e,t){t?.merge&&u.set(e,t.merge),l.has(e)||l.set(e,new Set)}function h(t,...n){if(!e.has(t))return;let r=c.get(t);r||(r=new Set,c.set(t,r));for(let e of n)r.add(e),l.has(e)||l.set(e,new Set),l.get(e).add(t)}function g(e){return l.get(e)??GL}function _(n){return e.get(n)??e.get(t.get(n))}function v(n){return e.has(n)||t.has(n)}function y(e,n){t.set(e,n)}function b(e){return t.get(e)??e}function x(e,t){let n=a.get(t);return n?.has(e)?n.find(e):e}function S(e,n){let r=x(e,n),i=s(n,r),a=o.get(i);return a||(a=crypto.randomUUID(),o.set(i,a),t.set(a,r)),a}function C(e,n,r,i,a,c){let l=s(e,n),u=s(e,i),d=o.get(l),f=o.get(u);if(o.delete(l),o.delete(u),!d&&!f)return;let p=d&&f?r>a||r===a&&n<i?d:f:d??f;o.set(s(e,c),p),t.set(p,c),d&&f&&t.set(p===d?f:d,c)}function w(e,t,r){let i=d(n,r),a=!i.get(e)?.has(t);return i.has(e)||i.set(e,new Set),i.has(t)||i.set(t,new Set),i.get(e).add(t),i.get(t).add(e),a}function ee(e,t){return n.get(t)?.get(e)??GL}function te(e,t,n){let r=w(e,t,n),i=f(n),a=i.find(e),o=i.find(t);if(a!==o){let r=i.component(a).size,s=i.component(o).size;i.union(e,t),C(n,a,r,o,s,i.find(e))}return r}function ne(e,t,n){let a=d(r,n),o=!a.get(e)?.has(t);a.has(e)||a.set(e,new Set),a.get(e).add(t);let s=d(i,n);return s.has(t)||s.set(t,new Set),s.get(t).add(e),o}function re(e,t){return r.get(t)?.get(e)??GL}function ie(e,t){return i.get(t)?.get(e)??GL}function ae(t,n){let r=a.get(n),i=r?.has(t)?r.component(t):void 0,o=[];if(i)for(let t of i){let n=e.get(t);n&&o.push(n)}else{let n=e.get(t);n&&o.push(n)}return o}function T(t,n,r){let i=a.get(t),o=new Set,s=[],c=r?r.map(e=>b(e)):n?l.get(n)??GL:e.keys();for(let t of c){let n=i?.has(t)?i.find(t):t;if(o.has(n))continue;o.add(n);let r=i?.has(t)?i.component(t):void 0,a=[];if(r)for(let t of r){let n=e.get(t);n&&a.push(n)}else{let n=e.get(t);n&&a.push(n)}a.length>0&&s.push(a)}return s}function E(){e.clear(),t.clear(),n.clear(),r.clear(),i.clear(),a.clear(),o.clear(),c.clear();for(let e of l.values())e.clear()}return{set:p,registerLabel:m,setLabel:h,labeled:g,get:_,has:v,alias:y,resolve:b,link:te,connect:w,neighbours:ee,root:x,componentId:S,edge:ne,targets:re,sources:ie,cluster:ae,clusters:T,clear:E}}const GL=new Set;function KL(e,t){let n={...t};for(let r in e){let i=e[r];if(Array.isArray(i)){let e=t[r];n[r]=Array.isArray(e)&&e.length>i.length?e:i}else n[r]=i??t[r]}return n}const qL=new EventTarget;function JL(e,t){qL.dispatchEvent(new CustomEvent(e,{detail:t}))}function YL(e,t){let n=e=>t(e.detail);return qL.addEventListener(e,n),()=>qL.removeEventListener(e,n)}function XL(e,t,n){let r=null,i=!1,a=e(()=>{r?(r({value:t,done:!1}),r=null):i=!0});return n?.abortSignal&&n.abortSignal.addEventListener(`abort`,()=>{a(),r&&r({value:void 0,done:!0})}),{async next(){return i?(i=!1,{value:t,done:!1}):new Promise(e=>{r=e})},async return(){return a(),{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}function ZL(e,t){let n=null,r=[],i=YL(e,e=>{n?(n({value:e,done:!1}),n=null):r.push(e)});return t?.abortSignal&&t.abortSignal.addEventListener(`abort`,()=>{i(),n&&n({value:void 0,done:!0})}),{async next(){return r.length>0?{value:r.shift(),done:!1}:new Promise(e=>{n=e})},async return(){return i(),{value:void 0,done:!0}},[Symbol.asyncIterator](){return this}}}function QL(e,t){return XL(t=>{let n=e.map(e=>YL(e,t));return()=>n.forEach(e=>e())},void 0,t)}function $L(e,t,n){let r=null;return XL(n=>{let i=e.map(e=>YL(e,()=>{r&&clearTimeout(r),r=setTimeout(n,t)}));return()=>{r&&clearTimeout(r),i.forEach(e=>e())}},void 0,n)}const eR=e=>{let t=e.filter(e=>e.value!=null);if(!t.length)return;let n=Math.max(...t.map(e=>e.score??0)),r=t.filter(e=>(e.score??0)===n),i=new Map;for(let e of r)i.set(e.value,(i.get(e.value)??0)+1);let a,o=0;for(let[e,t]of i){let n=t>o||t===o&&a!=null&&Number(e)>Number(a);(a==null||n)&&(a=e,o=t)}return a==null?void 0:{value:a,tier:n}},tR=e=>eR(e.map(e=>({value:e.episodeCount,score:e.score})))?.value,nR=e=>{let t=e.releaseDate?Date.parse(e.releaseDate):NaN;return Number.isFinite(t)?Math.floor(t/864e5):void 0},rR=(e,t)=>{let n=new Map;for(let t of e){let e=nR(t);if(e==null||t.episodeNumber==null)continue;let r=n.get(e)??new Set;r.add(t.episodeNumber),n.set(e,r)}if(!n.size)return;let r=new Map;for(let e of t){let t=nR(e);if(t==null||e.episodeNumber==null)continue;let i=new Set([...n.get(t-1)??[],...n.get(t)??[],...n.get(t+1)??[]]);if(i.size!==1)continue;let a=e.episodeNumber-[...i][0];r.set(a,(r.get(a)??0)+1)}let i=[...r.entries()].sort((e,t)=>t[1]-e[1]),[a,o]=i[0]??[];if(!(a==null||o==null||o<2)&&!(i[1]&&i[1][1]===o))return a},iR=(e,t)=>{let n=eR(e.map(e=>({value:e.episodeCount,score:e.score})));if(!n)return[...t];let{value:r,tier:i}=n,a=e.filter(e=>e.episodeCount===r),o=new Set(a.map(e=>e.origin)),s=new Set(e.filter(e=>(e.score??0)>=i).map(e=>e.origin)),c=new Set(e.map(e=>e.origin));if(a.length<2)return t.filter(e=>c.has(e.origin));let l=e=>!o.has(e.origin)&&!s.has(e.origin);return t.filter(e=>!l(e)||e.episodeNumber==null||e.episodeNumber>=1&&e.episodeNumber<=r)},aR=(e,t)=>{let n=new Map,r=tR(e);if(r==null)return n;let i=new Set(e.filter(e=>e.episodeCount===r).map(e=>e.origin));if(!i.size)return n;let a=t.filter(e=>i.has(e.origin));if(!a.length)return n;for(let e of new Set(t.map(e=>e.origin))){if(i.has(e))continue;let r=t.filter(t=>t.origin===e),o=rR(a,r);if(o!=null)for(let e of r)e.episodeNumber!=null&&n.set(e.uri,{...e,episodeNumber:e.episodeNumber-o})}return n},oR=`media:same_as`,sR=`container:same_as`,cR=new Set([`imdb`]),lR=e=>e.slice(0,e.indexOf(`:`)),uR=`episode:same_as`,dR=`has_episode`,fR={RUN:oR,CONTAINER:sR,EPISODE:uR},pR={RUN:`asserted:media_same_as`,CONTAINER:`asserted:container_same_as`,PART_OF:`asserted:media_part_of`},mR=`media:part_of`,U=WL(),hR=new Map;U.registerLabel(`media`,{merge:KL}),U.registerLabel(`episode`,{merge:KL});const gR=e=>cR.has(lR(e))?`CONTAINER`:U.get(e)?.scope??`RUN`,_R=e=>e===`CONTAINER`?sR:oR,vR=e=>e.scope!==`CONTAINER`,yR=(e,t)=>e<t?-1:+(e>t),bR=e=>e.map(e=>e.uri).sort()[0]??``,xR=new Set([`uri`,`origin`,`id`,`scope`]),SR=e=>e.scope!==`CONTAINER`&&Object.entries(e).every(([e,t])=>xR.has(e)||t==null||Array.isArray(t)&&t.length===0),CR=({mediaUri:e,handleUri:t,relation:n})=>`${e}\0${t}\0${n??`SAME_AS`}`,wR=new Map,TR=(e,t)=>{let n=wR.get(e);n||wR.set(e,n=new Map),n.set(CR(t),t)};async function ER(e,t){let n=!1,r=[];for(let t of e){if(SR(t))continue;let e=!U.has(t.uri),i=gR(t.uri)===`CONTAINER`?`CONTAINER`:t.scope??`RUN`;U.set(t.uri,{...t,scope:i},{addLabels:[`media`]}),e&&(n=!0,r.push(t.uri))}let i=[...t];for(let e of r){let t=wR.get(e);t&&(wR.delete(e),i.push(...t.values()))}for(let e of i){let{mediaUri:t,handleUri:r,relation:i}=e;if(i===`INCLUDES`)continue;let a=[t,r].filter(e=>!U.has(e));if(a.length){for(let t of a)TR(t,e);continue}let o=i??`SAME_AS`,s=gR(t);if(s!==gR(r)){let[e,i]=s===`RUN`?[t,r]:[r,t];U.edge(e,i,pR.PART_OF),U.edge(e,i,mR)&&(n=!0)}else o===`SAME_AS`?(U.connect(t,r,s===`CONTAINER`?pR.CONTAINER:pR.RUN),U.link(t,r,_R(s))&&(n=!0)):(U.edge(t,r,pR.PART_OF),U.edge(t,r,mR)&&(n=!0))}n&&JL(`media:changed`,{})}function DR(e){let t=!1;for(let[n,r]of e)gR(n)===`CONTAINER`||gR(r)===`CONTAINER`||U.link(n,r,oR)&&(t=!0);return t&&JL(`media:changed`,{}),t}function OR(e){let t=!1;for(let[n,r]of e)gR(n)!==`CONTAINER`||gR(r)!==`CONTAINER`||U.link(n,r,sR)&&(t=!0);return t&&JL(`media:changed`,{}),t}function kR(e){let t=!1;for(let[n,r]of e)gR(n)!==`RUN`||gR(r)!==`CONTAINER`||U.edge(n,r,mR)&&(t=!0);return t&&JL(`media:changed`,{}),t}async function AR(e){let t=U.resolve(e);return U.labeled(`media`).has(t)?U.cluster(t,_R(gR(t))):[]}function jR(e){let t=new Set,n=new Set(e.map(e=>e.uri)),r=[];for(let i of e)for(let e of U.targets(i.uri,mR)){let i=U.cluster(e,_R(gR(e)));if(!i.some(e=>n.has(e.uri)))for(let e of i)t.has(e.uri)||(t.add(e.uri),r.push(e))}return r}function MR(e){let t=new Set,n=[];for(let r of e)for(let e of U.sources(r.uri,mR)){if(!U.has(e)||gR(e)!==`RUN`)continue;let r=U.cluster(e,oR),i=bR(r);t.has(i)||(t.add(i),n.push(r))}return n}const NR=e=>Math.min(...e.map(e=>{let t=e.startDate?Date.parse(e.startDate):NaN;return Number.isNaN(t)?1/0:t}));function PR(e){if(e.some(vR))return e;let t=MR(e);return t.length?t.sort((e,t)=>NR(e)-NR(t)||yR(bR(e),bR(t)))[0]:e}async function FR(e){let t=await AR(e);if(!t.length&&qS(e)){let n=ZS(e);for(let e of n?.handleUris??[]){let n=await AR(e);if(n.length){if(n.some(vR)){t=n;break}t.length||(t=n)}}}return PR(t)}async function IR(e){let t=e?void 0:`media`,n=U.clusters(oR,t,e).filter(e=>e.some(vR)),r=new Set(n.flatMap(e=>e.map(e=>e.uri))),i=U.clusters(sR,t,e).map(e=>e.filter(e=>!vR(e)&&!r.has(e.uri))).filter(e=>e.length>0);return[...n,...i]}function LR(e){let t=new Set;for(let n of e)if(n.some(vR))for(let e of jR(n))t.add(e.uri);return e.filter(e=>e.some(vR)||!e.some(e=>t.has(e.uri)))}async function RR(e,t){for(let t of e)U.set(t.uri,t,{addLabels:[`episode`]}),U.edge(t.mediaUri,t.uri,dR);for(let{episodeUri:e,handleUri:n,relation:r}of t)r!==`INCLUDES`&&((r??`SAME_AS`)===`SAME_AS`?U.link(e,n,uR):U.edge(e,n,`episode:part_of`));JL(`episode:changed`,{})}async function zR(e){let t=await BR(e.map(e=>e.uri)),n=aR(e,t.flat());return t.map(t=>iR(e,t.map(e=>n.get(e.uri)??e))).filter(e=>e.length)}async function BR(e){let t=new Set,n=[];for(let r of e)for(let e of U.targets(r,dR))if(!t.has(e)){t.add(e);let r=U.get(e);r&&n.push(r)}let r=new Set,i=[];for(let e of n){if(r.has(e.uri))continue;let t=U.cluster(e.uri,uR);for(let e of t)r.add(e.uri);i.push(t)}return VR(i)}const VR=e=>{let t=new Map,n=[];for(let r of e){let e=r.map(e=>e.episodeNumber).find(e=>typeof e==`number`&&Number.isInteger(e)&&e>0);if(e==null){n.push(r);continue}let i=t.get(e);if(i)i.push(...r);else{let i=[...r];t.set(e,i),n.push(i)}}return n};async function HR(e){for(let t of e){let e=hR.get(t.id);hR.set(t.id,e?KL(t,e):t)}JL(`origin:changed`,{})}async function UR(e){return hR.get(e)??null}async function WR(e,t){let n;return n=e.length>0?e.map(e=>hR.get(e)).filter(e=>e!=null):[...hR.values()].sort((e,t)=>e.name.localeCompare(t.name)),t?.length&&(n=n.filter(e=>t.every(t=>t===`IS_API_ONLY`?e.isApiOnly:!e.isApiOnly))),n}let GR=function(e){return e.HOME=`HOME`,e.MEDIA=`MEDIA`,e.MEDIA_EPISODE=`MEDIA_EPISODE`,e.SEARCH=`SEARCH`,e.SEARCH_LEGACY=`SEARCH_LEGACY`,e.LEGAL=`LEGAL`,e.PRIVACY=`PRIVACY`,e.SETTINGS=`SETTINGS`,e.WATCH=`WATCH`,e.PARTY=`PARTY`,e.DEBUG_TRACE=`DEBUG_TRACE`,e.LOGIN_CALLBACK=`LOGIN_CALLBACK`,e}({});const KR={HOME:()=>`/`,MEDIA:({uri:e})=>`/media/${e}`,MEDIA_EPISODE:({uri:e,mediaUri:t})=>`/media/${e}/${t}`,SEARCH:()=>`/search`,SEARCH_LEGACY:({query:e})=>`/search/${encodeURIComponent(e)}`,LEGAL:()=>`/legal`,PRIVACY:()=>`/privacy`,SETTINGS:()=>`/settings`,WATCH:({mediaUri:e,episodeUri:t,sourceUri:n})=>`/watch/${e}/${t}${n?`/${n}`:``}`,PARTY:()=>`/party`,DEBUG_TRACE:()=>`/debug/trace`,LOGIN_CALLBACK:()=>`/login/callback`},qR=(e,t)=>KR[e](t),JR=e=>{let t=[];e.includes(`ANIME`)&&t.push(`ANIME`);let n=e.find(e=>e===`MOVIE`||e===`SERIES`);return n&&t.push(n),t};function YR(e){return[...e].sort((e,t)=>(t.score??-1)-(e.score??-1))}const XR=e=>{let t=e.find(e=>e.season);return{season:t?.season??null,seasonYear:(t?t.seasonYear:e.find(e=>e.seasonYear!==null)?.seasonYear)??null}},ZR=e=>{let t=new Set,n=[];for(let r of e??[]){let e=r.toLowerCase();!r||t.has(e)||(t.add(e),n.push(r))}return n};function QR(e,t){let n=new Set,r=[];for(let i of t)n.has(i[e])||(n.add(i[e]),r.push(i));return r}const $R=e=>({node:e,relation:`SAME_AS`}),ez=e=>({node:e,relation:`PART_OF`}),tz=e=>({node:e,relation:`SAME_AS`}),nz=e=>(e??[]).filter(e=>e.relation===`SAME_AS`).map(e=>e.node.uri),rz=new WeakMap;function iz(e){if(rz.has(e))return rz.get(e);let t=e.handles?[e,...e.handles.flatMap(t=>t?.node?t.relation===`PART_OF`?[{...t.node,handles:[]}]:iz(t.node):(console.warn(`a handle of ${e.uri} names no node and was skipped`),[]))]:[e];return e.handles&&rz.set(e,t),t}function az(e){return{_id:e.uri,uri:e.uri,origin:e.origin,id:e.id,url:e.url,score:e.score,type:e.type,categories:e.categories??[],status:e.status,titles:e.titles??[],descriptions:e.descriptions??[],shortDescriptions:e.shortDescriptions??[],trailers:e.trailers??[],covers:e.covers??[],banners:e.banners??[],averageScore:e.averageScore,popularity:e.popularity,startDate:e.startDate,endDate:e.endDate,isAdult:e.isAdult,episodeCount:e.episodeCount,nextAiringEpisode:e.nextAiringEpisode,season:e.season,seasonYear:e.seasonYear,genres:e.genres??[],tags:e.tags??[],scope:e.scope,episodes:[],handles:[],relations:(e.relations??[]).map(oz),franchise:e.franchise??null}}function oz(e){return{relation:e.relation,format:e.format,node:{_id:e.uri,uri:e.uri,origin:e.origin,id:e.id,url:e.url,score:null,type:null,categories:[],status:e.status,titles:e.titles??[],descriptions:[],shortDescriptions:[],trailers:[],covers:e.covers??[],banners:[],averageScore:null,popularity:null,startDate:e.startDate,endDate:null,isAdult:null,episodeCount:e.episodeCount,nextAiringEpisode:null,season:null,seasonYear:null,genres:[],tags:[],scope:`RUN`,episodes:[],handles:[],relations:[]}}}function sz(e,t){let n=new Set(t.map(e=>e.uri)),r=new Set,i=[];for(let t of e){if(!t?.node?.uri||n.has(t.node.uri))continue;let e=`${t.relation}\u0000${t.node.uri}`;r.has(e)||(r.add(e),i.push(t))}return i}const cz=e=>e.every(e=>e.scope===`CONTAINER`)?`CONTAINER`:`RUN`;function lz(e){return{_id:e.uri,uri:e.uri,origin:e.origin,id:e.id,url:e.url,embedUrl:e.embedUrl,mediaUri:e.mediaUri,score:e.score,titles:e.titles??[],descriptions:e.descriptions??[],shortDescriptions:e.shortDescriptions??[],thumbnails:e.thumbnails??[],releaseDate:e.releaseDate,seasonNumber:e.seasonNumber,episodeNumber:e.episodeNumber,absoluteEpisodeNumber:e.absoluteEpisodeNumber,runtime:e.runtime,handles:[]}}const uz=(e,t)=>U.componentId(e[0],fR[t]);function dz(e){let t=e.filter(WS),n=[...t.length?t:e].sort();return{uri:`ag:(${n.join(`,`)})`,id:`(${n.join(`,`)})`}}function fz(e,t){if(e.length===0)throw Error(`Cannot aggregate empty cluster`);if(e.length===1){let t=e[0],n=uz([t.uri],cz(e));return{...az(t),_id:n,scope:cz(e),handles:[$R(az(t)),...jR(e).map(e=>ez(az(e)))]}}let n=[...e].sort((e,t)=>(t.score??0)-(e.score??0)),{uri:r,id:i}=dz(e.map(e=>e.uri)),a=uz(e.map(e=>e.uri),cz(e)),o=n.reduce((e,t)=>{let n=az(t);return{...n,...e,url:e.url??n.url,type:e.type??n.type,status:e.status??n.status,averageScore:e.averageScore??n.averageScore,popularity:e.popularity??n.popularity,startDate:e.startDate??n.startDate,endDate:e.endDate??n.endDate,isAdult:e.isAdult??n.isAdult,episodeCount:e.episodeCount??n.episodeCount,nextAiringEpisode:e.nextAiringEpisode??n.nextAiringEpisode,categories:[...e.categories??[],...n.categories??[]],genres:[...e.genres??[],...n.genres??[]],tags:[...e.tags??[],...n.tags??[]],titles:[...e.titles??[],...t.titles??[]],descriptions:[...e.descriptions??[],...t.descriptions??[]],shortDescriptions:[...e.shortDescriptions??[],...t.shortDescriptions??[]],covers:[...e.covers??[],...t.covers??[]],banners:[...e.banners??[],...t.banners??[]],trailers:[...e.trailers??[],...t.trailers??[]],relations:[...e.relations??[],...n.relations??[]],franchise:e.franchise??n.franchise}},{_id:a,uri:r,id:i,origin:`ag`,url:`${t}/${qR(GR.MEDIA,{uri:r}).replace(/^\//,``)}`,score:Math.max(...e.map(e=>e.score??0)),scope:cz(e),handles:[...n.map(e=>$R(az(e))),...jR(e).map(e=>ez(az(e)))],episodes:[]});return{...o,episodeCount:tR(e)??o.episodeCount??null,relations:sz(o.relations??[],e),categories:JR(o.categories??[]),...XR(n),genres:ZR(o.genres),tags:ZR(o.tags),titles:QR(`title`,YR(o.titles??[])),descriptions:YR(o.descriptions??[]),shortDescriptions:YR(o.shortDescriptions??[]),covers:YR(o.covers??[]),banners:YR(o.banners??[]),trailers:QR(`uri`,o.trailers??[])}}function pz(e,t){if(e.length===0)throw Error(`Cannot aggregate empty cluster`);if(e.length===1){let t=e[0];return{...lz(t),_id:uz([t.uri],`EPISODE`),handles:[tz(lz(t))]}}let n=[...e].sort((e,t)=>(t.score??0)-(e.score??0)),{uri:r,id:i}=dz(e.map(e=>e.uri)),a=uz(e.map(e=>e.uri),`EPISODE`),o=n.reduce((e,t)=>{let n=lz(t);return{...n,...e,url:e.url??n.url,embedUrl:e.embedUrl??n.embedUrl,releaseDate:e.releaseDate??n.releaseDate,seasonNumber:e.seasonNumber??n.seasonNumber,episodeNumber:e.episodeNumber??n.episodeNumber,absoluteEpisodeNumber:e.absoluteEpisodeNumber??n.absoluteEpisodeNumber,runtime:e.runtime??n.runtime,titles:[...e.titles??[],...t.titles??[]],descriptions:[...e.descriptions??[],...t.descriptions??[]],shortDescriptions:[...e.shortDescriptions??[],...t.shortDescriptions??[]],thumbnails:[...e.thumbnails??[],...t.thumbnails??[]]}},{_id:a,uri:r,id:i,origin:`ag`,url:`${t}/${qR(GR.MEDIA,{uri:r}).replace(/^\//,``)}`,mediaUri:r,score:Math.max(...e.map(e=>e.score??0)),handles:n.map(e=>tz(lz(e)))});return{...o,titles:QR(`title`,YR(o.titles??[])),descriptions:YR(o.descriptions??[]),shortDescriptions:YR(o.shortDescriptions??[]),thumbnails:YR(o.thumbnails??[])}}const mz=e=>({uri:e.uri,origin:e.origin,id:e.id,url:e.url??null,score:e.score??null,type:e.type??null,categories:e.categories??[],status:e.status??null,titles:e.titles??[],descriptions:e.descriptions??[],shortDescriptions:e.shortDescriptions??[],trailers:e.trailers??[],covers:e.covers??[],banners:e.banners??[],averageScore:e.averageScore??null,popularity:e.popularity??null,startDate:e.startDate??null,endDate:e.endDate??null,isAdult:e.isAdult??null,episodeCount:e.episodeCount??null,nextAiringEpisode:e.nextAiringEpisode??null,season:e.season??null,seasonYear:e.seasonYear??null,genres:e.genres??[],tags:e.tags??[],scope:e.scope??`RUN`,relations:(e.relations??[]).flatMap(e=>{let t=e?.node;return t?.uri?[{relation:e.relation,format:e.format??null,uri:t.uri,origin:t.origin,id:t.id,url:t.url??null,titles:t.titles??[],covers:t.covers??[],status:t.status??null,episodeCount:t.episodeCount??null,startDate:t.startDate??null}]:[]}),franchise:e.franchise?{nodes:(e.franchise.nodes??[]).map(e=>({uri:e.uri,titles:e.titles??[],covers:e.covers??[],format:e.format??null,status:e.status??null,episodeCount:e.episodeCount??null,startDate:e.startDate??null})),edges:(e.franchise.edges??[]).map(e=>({from:e.from,to:e.to,relation:e.relation}))}:null}),hz=/^[a-z0-9][a-z0-9-]{0,31}$/,gz=(e,t)=>{let n=Array.isArray(e.sources)&&e.sources.length?e.sources:[e],r=[],i=[],a=new Set;for(let e of n){let n=typeof e.origin==`string`?e.origin:``;if(!hz.test(n)){i.push({origin:n||`(none)`,reason:`origin must be a short lowercase token`});continue}if(a.has(n)){i.push({origin:n,reason:`declared twice by '${t}'`});continue}a.add(n),r.push({source:e,meta:{origin:n,originUrl:typeof e.originUrl==`string`?e.originUrl:``,name:typeof e.name==`string`&&e.name?e.name.slice(0,64):n,icon:typeof e.icon==`string`?e.icon:null,color:typeof e.color==`string`?e.color:null,isApiOnly:e.isApiOnly===!0,metadataOnly:e.metadataOnly===!0}})}return{sources:r,rejected:i}},_z=e=>typeof e==`object`&&!!e,vz=e=>{if(_z(e)){if(typeof e.uri==`string`)return e;if(typeof e.origin==`string`&&typeof e.id==`string`)return{...e,uri:`${e.origin}:${e.id}`}}},yz=(e,t)=>{if(_z(e)&&`node`in e)return _z(e.node)?{...e,node:xz(e.node,t),relation:typeof e.relation==`string`?e.relation:`SAME_AS`}:void 0;let n=vz(e);return n?{node:xz(n,t),relation:`SAME_AS`}:void 0},bz=(e,t)=>Array.isArray(e)&&t>0?e.map(e=>yz(e,t-1)).filter(e=>e!==void 0):[],xz=(e,t=4)=>{if(!_z(e))return e;let n=Array.isArray(e.episodes)?e.episodes.map(e=>_z(e)?{...e,handles:bz(e.handles,1)}:e):e.episodes;return{...e,handles:bz(e.handles,t),episodes:n}},Sz=(e,t)=>{if(!_z(t))return t;if(e===`mediaPage`){let e=t.mediaPage?.nodes;return Array.isArray(e)?{...t,mediaPage:{...t.mediaPage,nodes:e.map(e=>xz(e))}}:t}return t[e]?{...t,[e]:xz(t[e])}:t};var Cz=class extends Error{phase;statement;constructor(e,t,n){super(t),this.name=`CypherError`,this.phase=e,this.statement=n}};const wz=(e,t)=>new Cz(`bind`,`not supported: ${e}`,t),Tz=e=>[{result:`Table ${e} has been created.`}],Ez=e=>[{result:`Table ${e} already exists.`}],Dz=(e,t,n)=>{if(e.table(t.name)){if(t.ifNotExists)return Ez(t.name);throw new Cz(`run`,`Binder exception: ${t.name} already exists in catalog.`,n)}let r=t.columns.filter(e=>e.primaryKey);if(r.length!==1)throw new Cz(`bind`,`node table ${t.name} declares ${r.length} primary keys, and exactly one is required`,n);return e.declareNode(t.name,t.columns),Tz(t.name)},Oz=(e,t,n)=>{if(e.table(t.name)){if(t.ifNotExists)return Ez(t.name);throw new Cz(`run`,`Binder exception: ${t.name} already exists in catalog.`,n)}if(!t.pairs.length)throw new Cz(`bind`,`rel table ${t.name} declares no FROM ... TO ... pair`,n);for(let r of t.pairs)for(let i of[r.from,r.to]){let r=e.table(i);if(!r)throw new Cz(`bind`,`rel table ${t.name} names ${i}, which is not declared`,n);if(r.kind!==`node`)throw new Cz(`bind`,`rel table ${t.name} names ${i}, which is a rel table`,n)}if(t.columns.some(e=>e.primaryKey))throw new Cz(`bind`,`rel table ${t.name} declares a PRIMARY KEY, which a rel table has no place for`,n);return e.declareRel(t.name,t.pairs,t.columns),Tz(t.name)},kz=e=>e.all().map((e,t)=>({id:t,name:e.name,type:e.kind===`node`?`NODE`:`REL`,"database name":`main(graph)`,comment:``})),Az=(e,t,n)=>{let r=new Set,i=e=>{throw new Cz(`bind`,e,n)},a=(t,n)=>{if(t.label){let n=e.table(t.label);if(!n)i(`no node table named ${t.label}`);else if(n.kind!==`node`)i(`${t.label} is a rel table, used as a node label`);else for(let e of t.properties)n.byName.has(e.name)||i(`${t.label} declares no column ${e.name}`)}else t.properties.length&&!t.variable&&i(`a node pattern with properties and no label cannot be resolved to a table`);for(let e of t.properties)c(e.value);t.variable&&r.add(t.variable),n&&!t.label&&t.variable&&!r.has(t.variable)&&i(`${t.variable} is written to before anything binds it`)},o=t=>{if(t.range&&(t.range.relVariable&&r.add(t.range.relVariable),t.range.nodeVariable&&r.add(t.range.nodeVariable),t.range.filter&&c(t.range.filter)),t.type){let n=e.table(t.type);if(!n)i(`no rel table named ${t.type}`);else if(n.kind!==`rel`)i(`${t.type} is a node table, used as a relationship type`);else for(let e of t.properties)n.byName.has(e.name)||i(`${t.type} declares no column ${e.name}`)}for(let e of t.properties)c(e.value);t.variable&&r.add(t.variable)},s=(e,t)=>{a(e.start,t);for(let n of e.steps)o(n.rel),a(n.node,t)},c=e=>{switch(e.kind){case`literal`:case`param`:return;case`variable`:r.has(e.name)||i(`${e.name} is used before anything binds it`);return;case`property`:c(e.target);return;case`list`:e.items.forEach(c);return;case`struct`:e.entries.forEach(e=>c(e.value));return;case`call`:e.args.forEach(c);return;case`cast`:c(e.value);return;case`case`:e.whens.forEach(e=>{c(e.when),c(e.then)}),e.otherwise&&c(e.otherwise);return;case`not`:c(e.value);return;case`and`:case`or`:c(e.left),c(e.right);return;case`compare`:c(e.left),c(e.right);return;case`in`:c(e.value),c(e.list);return;case`startsWith`:c(e.value),c(e.prefix);return;case`isNull`:c(e.value);return;case`exists`:{let t=new Set(r);e.pattern.forEach(e=>s(e,!1)),e.where&&c(e.where),r.clear();for(let e of t)r.add(e);return}}},l=e=>{switch(e.kind){case`unwind`:c(e.source),r.add(e.as);return;case`match`:e.patterns.forEach(e=>s(e,!1)),e.where&&c(e.where);return;case`with`:{e.items.forEach(e=>c(e.value));let t=new Set(e.items.map(e=>e.as));r.clear();for(let e of t)r.add(e);e.where&&c(e.where);return}}},u=t=>{switch(t.kind){case`create`:t.patterns.forEach(e=>s(e,!0));return;case`merge`:{a(t.node,!1),t.node.label||i(`MERGE needs a label`);let r=e.node(t.node.label??``);if(r){let e=t.node.properties.map(e=>e.name);if(e.length!==1||e[0]!==r.primaryKey.name)throw wz(`MERGE on ${e.join(`, `)||`no column`} rather than on the primary key ${r.primaryKey.name}`,n)}t.onCreate.forEach(e=>d(e.target,e.value)),t.onMatch.forEach(e=>d(e.target,e.value));return}case`set`:t.assignments.forEach(e=>d(e.target,e.value));return;case`delete`:t.targets.forEach(c);return}},d=(e,t)=>{if(c(t),e.kind!==`property`){i(`SET assigns to a property, as in SET n.col = value`);return}c(e.target)};if(t.reading.forEach(l),t.updating.forEach(u),t.returning){t.returning.items.forEach(e=>c(e.value));for(let e of t.returning.items)r.add(e.as);t.returning.orderBy.forEach(e=>c(e.value))}};var jz=class{tables=new Map;counter=0;undo;restored;all(){return[...this.tables.values()]}table(e){return this.tables.get(e)}node(e){let t=this.tables.get(e);return t?.kind===`node`?t:void 0}rel(e){let t=this.tables.get(e);return t?.kind===`rel`?t:void 0}declareNode(e,t){let n=t.find(e=>e.primaryKey);if(!n)throw Error(`node table ${e} declares no PRIMARY KEY`);let r={kind:`node`,name:e,columns:t,primaryKey:n,byName:new Map(t.map(e=>[e.name,e])),rows:new Map};return this.tables.set(e,r),r}declareRel(e,t,n){let r={kind:`rel`,name:e,pairs:t,columns:n,byName:new Map(n.map(e=>[e.name,e])),edges:new Set,byKey:n.some(e=>e.name===`key`)?new Map:void 0};return this.tables.set(e,r),r}transact(e){if(this.undo)return e();let t=[];this.undo=t,this.restored=new Set;try{let t=e();return this.undo=void 0,this.restored=void 0,t}catch(e){this.undo=void 0;let n=this.restored??new Set;for(let e=t.length-1;e>=0;--e)t[e]();this.restored=void 0;for(let e of n)Nz(e);throw e}}resort(e){this.restored?.add(e)}record(e){this.undo?.push(e)}createNode(e,t){let n=t[e.primaryKey.name]??null;if(e.rows.has(n))throw Error(`Found duplicated primary key value ${String(n)}`);let r={table:e,key:n,seq:this.counter+=1,props:t,deleted:!1,out:new Map,in:new Map};return e.rows.set(n,r),this.record(()=>{e.rows.delete(n)}),r}createEdge(e,t,n,r){let i={table:e,seq:this.counter+=1,from:t,to:n,props:r,deleted:!1};e.edges.add(i),Pz(t.out,e).add(i),Pz(n.in,e).add(i);let a=e.byKey?r.key??null:void 0;if(e.byKey&&a!==void 0){let t=e.byKey.get(a)??new Set;t.add(i),e.byKey.set(a,t)}return this.record(()=>{if(e.edges.delete(i),Mz(t.out,e,i),Mz(n.in,e,i),e.byKey&&a!==void 0){let t=e.byKey.get(a);t?.delete(i),t&&!t.size&&e.byKey.delete(a)}}),i}setProperty(e,t,n){let r=Object.prototype.hasOwnProperty.call(e.props,t),i=e.props[t];e.props[t]=n,this.record(()=>{r?e.props[t]=i:delete e.props[t]})}deleteEdge(e){if(e.deleted)return;let{table:t,from:n,to:r}=e;e.deleted=!0,t.edges.delete(e),n.out.get(t)?.delete(e),r.in.get(t)?.delete(e);let i=t.byKey?e.props.key??null:void 0;t.byKey&&i!==void 0&&t.byKey.get(i)?.delete(e),this.record(()=>{if(e.deleted=!1,t.edges.add(e),Pz(n.out,t).add(e),Pz(r.in,t).add(e),t.byKey&&i!==void 0){let n=t.byKey.get(i)??new Set;n.add(e),t.byKey.set(i,n)}this.resort(t.edges),this.resort(n.out.get(t)),this.resort(r.in.get(t))})}edgesOf(e){let t=[];for(let n of e.out.values())t.push(...n);for(let n of e.in.values())t.push(...n);return t}deleteNode(e){if(e.deleted)return;let{key:t}=e;e.deleted=!0,e.table.rows.delete(t),this.record(()=>{e.deleted=!1,e.table.rows.set(t,e),this.resort(e.table.rows)})}};const Mz=(e,t,n)=>{let r=e.get(t);r&&(r.delete(n),r.size||e.delete(t))},Nz=e=>{if(e instanceof Set){let t=[...e].sort((e,t)=>e.seq-t.seq);e.clear();for(let n of t)e.add(n);return}let t=[...e.entries()].sort((e,t)=>e[1].seq-t[1].seq);e.clear();for(let[n,r]of t)e.set(n,r)},Pz=(e,t)=>{let n=e.get(t);if(n)return n;let r=new Set;return e.set(t,r),r},Fz=e=>{if(typeof e!=`object`||!e||e instanceof Date)return e;if(Array.isArray(e))return e.map(Fz);let t={};for(let[n,r]of Object.entries(e))t[n]=Fz(r);return t},Iz=e=>Number.isFinite(e)&&Math.floor(e)===e,Lz=(e,t,n,r)=>{if(e==null)return null;let i=e=>{throw new Cz(`run`,`Binder exception: ${n} expected ${Rz(t)} but got ${e}`,r)};switch(t.kind){case`STRING`:return typeof e==`string`?e:i(typeof e);case`INT64`:if(typeof e==`number`)return Iz(e)&&Number.isSafeInteger(e)?e:i(`a non integer`);if(typeof e==`string`&&/^[+-]?\d+(\.0+)?$/.test(e.trim())){let t=Number(e.trim());if(Number.isSafeInteger(t))return t}return i(typeof e==`string`?`the string ${JSON.stringify(e)}`:typeof e);case`DOUBLE`:return typeof e==`number`?e:typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e))?Number(e):i(typeof e);case`BOOLEAN`:return typeof e==`boolean`?e:i(typeof e);case`JSON`:return typeof e==`string`?e:i(typeof e);case`TIMESTAMP`:if(e instanceof Date)return e;if(typeof e==`string`){let t=new Date(e);return Number.isNaN(t.getTime())?i(`an unparseable timestamp`):t}return i(typeof e);case`LIST`:return Array.isArray(e)?e.length?e.map(e=>Lz(e,t.of,`${n} element`,r)):null:i(typeof e);case`MAP`:{if(typeof e!=`object`||!e||Array.isArray(e)||e instanceof Date)return i(typeof e);let a={};for(let[i,o]of Object.entries(e))a[i]=Lz(o,t.value,`${n}[${i}]`,r);return a}}},Rz=e=>{switch(e.kind){case`LIST`:return`${Rz(e.of)}[]`;case`MAP`:return`MAP(${Rz(e.key)}, ${Rz(e.value)})`;default:return e.kind}},zz=(e,t)=>{if(e===null||t===null)return null;if(e instanceof Date||t instanceof Date)return!(e instanceof Date)||!(t instanceof Date)?!1:e.getTime()===t.getTime();if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(zz(e[n],t[n])!==!0)return!1;return!0}if(typeof e==`object`||typeof t==`object`){if(typeof e!=`object`||typeof t!=`object`||e===null||t===null)return!1;let n=Object.entries(e).sort(Bz),r=Object.entries(t).sort(Bz);return n.length===r.length?n.every(([e,t],n)=>r[n][0]===e&&zz(t,r[n][1])===!0):!1}return e===t},Bz=(e,t)=>e[0]<t[0]?-1:+(e[0]>t[0]),Vz=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1){let n=Hz(e.charCodeAt(r)),i=Hz(t.charCodeAt(r));if(n!==i)return n<i?-1:1}return e.length===t.length?0:e.length<t.length?-1:1},Hz=e=>e>=55296&&e<=57343?e+65536:e,Uz=(e,t)=>e===null&&t===null?0:e===null?1:t===null?-1:typeof e==`string`&&typeof t==`string`?Vz(e,t):typeof e==`number`&&typeof t==`number`?e===t?0:e<t?-1:1:typeof e==`boolean`&&typeof t==`boolean`?e===t?0:e?1:-1:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime()?0:e.getTime()<t.getTime()?-1:1:Vz(String(e),String(t)),Wz=(e,t,n)=>{if(e===null)return null;if(typeof e==`string`)switch(t.kind){case`BOOLEAN`:{let t=e.trim().toLowerCase();if(t===`true`)return!0;if(t===`false`)return!1;throw new Cz(`run`,`Conversion exception: Cast failed. Could not convert "${e}" to BOOLEAN.`,n)}case`INT64`:case`DOUBLE`:case`TIMESTAMP`:return Lz(e,t,`cast`,n);default:return Lz(e,t,`cast`,n)}return typeof e==`number`&&t.kind===`STRING`||typeof e==`boolean`&&t.kind===`STRING`?String(e):typeof e==`number`&&t.kind===`INT64`&&!Number.isInteger(e)?Math.trunc(e):Lz(e,t,`cast`,n)},Gz=(e,t)=>{let n=[new Map];for(let r of t.reading)n=Kz(e,r,n);if(t.updating.length)for(let r of t.updating)n=lB(e,r,n);return t.returning?_B(e,t.returning,n):[]},Kz=(e,t,n)=>{switch(t.kind){case`unwind`:{let r=[];for(let i of n){let n=wB(e,i,t.source);if(n!==null){if(!Array.isArray(n))throw new Cz(`run`,`UNWIND expects a list, got ${typeof n}`,e.cypher);for(let e of n){let n=new Map(i);n.set(t.as,{kind:`value`,value:e}),r.push(n)}}}return r}case`match`:{let r=[];for(let i of n){let n=[i];for(let r of t.patterns)n=n.flatMap(t=>tB(e,t,r));let a=t.where?n.filter(n=>wB(e,n,t.where)===!0):n;if(a.length){r.push(...a);continue}if(!t.optional)continue;let o=new Map(i);for(let e of Xz(t.patterns))o.has(e)||o.set(e,{kind:`value`,value:null});r.push(o)}return r}case`with`:{let r=t.items.some(e=>gB(e.value))?Jz(e,t.items,n):n.map(n=>qz(e,t.items,n));return t.where?r.filter(n=>wB(e,n,t.where)===!0):r}}},qz=(e,t,n)=>{let r=new Map;for(let i of t){if(i.value.kind===`variable`&&n.has(i.value.name)){r.set(i.as,n.get(i.value.name));continue}r.set(i.as,{kind:`value`,value:wB(e,n,i.value)})}return r},Jz=(e,t,n)=>{let r=t.filter(e=>!gB(e.value)),i=new Map;for(let t of n){let n=qz(e,r,t),a=bB(Object.fromEntries([...n].map(([e,t])=>[e,t.kind===`value`?t.value:`${t.kind}#${Yz(t)}`]))),o=i.get(a);o?o.members.push(t):i.set(a,{binding:n,members:[t]})}return[...i.values()].map(n=>{let i=new Map(n.binding);for(let a of t)r.includes(a)||i.set(a.as,{kind:`value`,value:SB(e,a.value,n.members)});return i})},Yz=e=>e.kind===`node`?e.node.seq:e.kind===`edge`?e.edge.seq:0,Xz=e=>{let t=[];for(let n of e){n.start.variable&&t.push(n.start.variable);for(let e of n.steps)e.rel.variable&&t.push(e.rel.variable),e.node.variable&&t.push(e.node.variable)}return t},Zz=(e,t,n)=>{if(!n.steps.length)return n;let r=n.steps[n.steps.length-1].node;return Qz(e,t,n.start)>=Qz(e,t,r)?n:$z(n)},Qz=(e,t,n)=>{if(n.variable&&t.has(n.variable))return 2;let r=n.label?e.store.node(n.label):void 0;return r&&n.properties.some(e=>e.name===r.primaryKey.name)?1:0},$z=e=>{let t=[e.start,...e.steps.map(e=>e.node)],n=e.steps.map(e=>e.rel).map(e=>({...e,direction:e.direction===`right`?`left`:e.direction===`left`?`right`:`undirected`}));return{start:t[t.length-1],steps:n.reverse().map((e,n)=>({rel:e,node:t[t.length-2-n]}))}},eB=(e,t,n)=>{if(n.steps.length!==1)return;let r=n.steps[0];if(r.rel.range||!r.rel.type||n.start.variable&&t.has(n.start.variable)||r.node.variable&&t.has(r.node.variable))return;let i=e.store.rel(r.rel.type);if(!i?.byKey)return;let a=r.rel.properties.find(e=>e.name===`key`);if(!a)return;let o=wB(e,t,a.value);return[...i.byKey.get(o??null)??[]]},tB=(e,t,n)=>{let r=n,i=eB(e,t,r);if(i){let n=r.steps[0],a=[];for(let o of i){let i=n.rel.direction===`undirected`?[{start:o.from,end:o.to},{start:o.to,end:o.from}]:n.rel.direction===`left`?[{start:o.to,end:o.from}]:[{start:o.from,end:o.to}];for(let s of i){let i=oB(e,t,r.start,s.start);if(!i)continue;let c=oB(e,i,n.node,s.end);c&&cB(e,c,n.rel.properties,o.props)&&(n.rel.variable&&c.set(n.rel.variable,{kind:`edge`,edge:o}),a.push(c))}}return a}let a=Zz(e,t,r),o=rB(e,t,a.start).map(n=>oB(e,t,a.start,n)).filter(e=>e!==void 0);r=a;for(let t of r.steps){let n=[];for(let i of o){let a=iB(i,r,t);if(a){if(t.rel.range){n.push(...nB(e,i,t,a));continue}for(let{edge:r,other:o}of sB(e,a,t.rel)){let a=oB(e,i,t.node,o);a&&cB(e,a,t.rel.properties,r.props)&&(t.rel.variable&&a.set(t.rel.variable,{kind:`edge`,edge:r}),n.push(a))}}}o=n}return o},nB=function*(e,t,n,r){let i=n.rel.range,a=new Set,o=function*(r,a){if(a.length<i.min)return;let o=oB(e,t,n.node,r);o&&(n.rel.variable&&o.set(n.rel.variable,{kind:`value`,value:a.map(e=>`edge#${e.seq}`)}),yield o)},s=function*(r,c){if(yield*o(r,c),!(c.length>=i.max))for(let{edge:o,other:l}of sB(e,r,n.rel)){if(!cB(e,t,n.rel.properties,o.props))continue;if(i.filter){let n=new Map(t);if(i.relVariable&&n.set(i.relVariable,{kind:`edge`,edge:o}),i.nodeVariable&&n.set(i.nodeVariable,{kind:`node`,node:l}),wB(e,n,i.filter)!==!0)continue}c.push(o);let r=`${c.map(e=>e.seq).join(`,`)}#${l.seq}`;a.has(r)||(a.add(r),yield*s(l,c)),c.pop()}};yield*s(r,[])},rB=(e,t,n)=>{let r=n.variable?t.get(n.variable):void 0;if(r)return r.kind===`node`?[r.node]:[];if(!n.label)return e.store.all().filter(e=>e.kind===`node`).flatMap(e=>[...e.rows.values()]);let i=e.store.node(n.label);if(!i)return[];let a=n.properties.find(e=>e.name===i.primaryKey.name);if(a){let n=wB(e,t,a.value),r=i.rows.get(n??null);return r?[r]:[]}return[...i.rows.values()]},iB=(e,t,n)=>{let r=e.get(aB);if(r?.kind===`node`)return r.node;let i=t.start.variable?e.get(t.start.variable):void 0;return i?.kind===`node`?i.node:void 0},aB=` from`,oB=(e,t,n,r)=>{if(n.label&&r.table.name!==n.label)return;if(n.variable){let e=t.get(n.variable);if(e&&(e.kind!==`node`||e.node!==r))return}if(!cB(e,t,n.properties,r.props))return;let i=new Map(t);return n.variable&&i.set(n.variable,{kind:`node`,node:r}),i.set(aB,{kind:`node`,node:r}),i},sB=function*(e,t,n){let r=n.type?[e.store.rel(n.type)].filter(e=>e!==void 0):e.store.all().filter(e=>e.kind===`rel`);for(let e of r){if(n.direction!==`left`)for(let n of t.out.get(e)??[])yield{edge:n,other:n.to};if(n.direction!==`right`)for(let n of t.in.get(e)??[])yield{edge:n,other:n.from}}},cB=(e,t,n,r)=>n.every(n=>zz(r[n.name]??null,wB(e,t,n.value))===!0),lB=(e,t,n)=>{switch(t.kind){case`create`:return n.map(n=>{let r=n;for(let n of t.patterns)r=uB(e,r,n);return r});case`merge`:return n.map(n=>pB(e,n,t));case`set`:for(let r of n)for(let n of t.assignments)mB(e,r,n);return n;case`delete`:for(let r of n)for(let n of t.targets){if(n.kind!==`variable`)throw new Cz(`run`,`DELETE takes a variable`,e.cypher);let i=r.get(n.name);if(!i)continue;if(i.kind===`edge`){e.store.deleteEdge(i.edge);continue}if(i.kind!==`node`)continue;let a=e.store.edgesOf(i.node);if(a.length&&!t.detach)throw new Cz(`run`,`Cannot delete node ${String(i.node.key)}: it has connected edges in table ${a[0].table.name}. Try DETACH DELETE instead.`,e.cypher);for(let t of a)e.store.deleteEdge(t);e.store.deleteNode(i.node)}return n}},uB=(e,t,n)=>{let r=t,i=dB(e,r,n.start);r=i.binding;for(let t of n.steps){let n=dB(e,r,t.node);if(r=n.binding,!t.rel.type)throw new Cz(`run`,`CREATE needs a relationship type`,e.cypher);let a=e.store.rel(t.rel.type);if(!a)throw new Cz(`run`,`no rel table named ${t.rel.type}`,e.cypher);let[o,s]=t.rel.direction===`left`?[n.node,i.node]:[i.node,n.node];if(!a.pairs.some(e=>e.from===o.table.name&&e.to===s.table.name))throw new Cz(`run`,`${a.name} declares no FROM ${o.table.name} TO ${s.table.name}`,e.cypher);let c=e.store.createEdge(a,o,s,fB(e,r,a,t.rel.properties));t.rel.variable&&r.set(t.rel.variable,{kind:`edge`,edge:c}),i={binding:r,node:n.node}}return r},dB=(e,t,n)=>{let r=n.variable?t.get(n.variable):void 0;if(r?.kind===`node`)return{binding:t,node:r.node};if(!n.label)throw new Cz(`run`,`CREATE needs a label on a new node`,e.cypher);let i=e.store.node(n.label);if(!i)throw new Cz(`run`,`no node table named ${n.label}`,e.cypher);let a=e.store.createNode(i,fB(e,t,i,n.properties)),o=new Map(t);return n.variable&&o.set(n.variable,{kind:`node`,node:a}),{binding:o,node:a}},fB=(e,t,n,r)=>{let i=new Map(r.map(e=>[e.name,e.value])),a={};for(let r of n.columns){let o=i.get(r.name),s=o?wB(e,t,o):r.defaultTo?wB(e,t,r.defaultTo):null;a[r.name]=Lz(s,r.type,`${n.name}.${r.name}`,e.cypher)}return a},pB=(e,t,n)=>{let r=e.store.node(n.node.label??``);if(!r)throw new Cz(`run`,`no node table named ${n.node.label}`,e.cypher);let i=n.node.properties[0],a=Lz(wB(e,t,i.value),r.primaryKey.type,`${r.name}.${r.primaryKey.name}`,e.cypher),o=r.rows.get(a),s=new Map(t);if(o){n.node.variable&&s.set(n.node.variable,{kind:`node`,node:o});for(let t of n.onMatch)mB(e,s,t);return s}let c=e.store.createNode(r,fB(e,t,r,n.node.properties));n.node.variable&&s.set(n.node.variable,{kind:`node`,node:c});for(let t of n.onCreate)mB(e,s,t);return s},mB=(e,t,n)=>{let{target:r}=n;if(r.kind!==`property`||r.target.kind!==`variable`)throw new Cz(`run`,`SET assigns to a property of a bound variable`,e.cypher);let i=t.get(r.target.name);if(!i||i.kind===`value`)return;let a=i.kind===`node`?i.node:i.edge,o=a.table,s=o.byName.get(r.name);if(!s)throw new Cz(`run`,`${o.name} declares no column ${r.name}`,e.cypher);if(s.primaryKey)throw new Cz(`run`,`${o.name}.${r.name} is a primary key and cannot be SET`,e.cypher);let c=Lz(wB(e,t,n.value),s.type,`${o.name}.${r.name}`,e.cypher);e.store.setProperty(a,r.name,c)},hB=new Set([`count`,`collect`,`max`,`min`,`sum`]),gB=e=>{switch(e.kind){case`call`:return hB.has(e.name)||e.args.some(gB);case`cast`:return gB(e.value);case`not`:return gB(e.value);case`and`:case`or`:return gB(e.left)||gB(e.right);case`compare`:return gB(e.left)||gB(e.right);case`list`:return e.items.some(gB);case`struct`:return e.entries.some(e=>gB(e.value));default:return!1}},_B=(e,t,n)=>{let r=t.items.some(e=>gB(e.value))?xB(e,t,n).map(e=>({row:e,binding:void 0})):n.map(n=>{let r={};for(let i of t.items)r[i.as]=Fz(wB(e,n,i.value));return{row:r,binding:n}});if(t.distinct&&(r=yB(r)),t.orderBy.length){let n=r.map((e,t)=>({entry:e,index:t}));n.sort((n,r)=>{for(let i of t.orderBy){let a=Uz(vB(e,t,n.entry,i.value),vB(e,t,r.entry,i.value))*(i.descending?-1:1);if(a!==0)return a}return n.index-r.index}),r=n.map(e=>e.entry)}let i=r.map(e=>e.row);return t.limit===void 0?i:i.slice(0,t.limit)},vB=(e,t,n,r)=>{if(r.kind===`variable`&&r.name in n.row)return n.row[r.name];if(n.binding)return wB(e,n.binding,r);throw wz(`ORDER BY a pattern variable in an aggregating RETURN, which has only its own columns`,e.cypher)},yB=e=>{let t=new Set,n=[];for(let r of e){let e=bB(r.row);t.has(e)||(t.add(e),n.push(r))}return n},bB=e=>e===null?`n`:e instanceof Date?`t:${e.toISOString()}`:Array.isArray(e)?`[${e.map(bB).join(`,`)}]`:typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>`${e}=${bB(t)}`).join(`,`)}}`:`${typeof e}:${String(e)}`,xB=(e,t,n)=>{let r=new Map,i=t.items.filter(e=>!gB(e.value));for(let t of n){let n={};for(let r of i)n[r.as]=Fz(wB(e,t,r.value));let a=bB(n),o=r.get(a);o?o.members.push(t):r.set(a,{row:n,members:[t]})}return!r.size&&!i.length&&r.set(``,{row:{},members:[]}),[...r.values()].map(n=>{let r={...n.row};for(let a of t.items)i.includes(a)||(r[a.as]=Fz(SB(e,a.value,n.members)));let a={};for(let e of t.items)a[e.as]=r[e.as]??null;return a})},SB=(e,t,n)=>{if(t.kind!==`call`||!hB.has(t.name))return n.length?wB(e,n[0],t):null;let r=t.star?n.map(()=>1):n.map(n=>wB(e,n,t.args[0])).filter(e=>e!==null),i=t.distinct?CB(r):r;switch(t.name){case`count`:return i.length;case`collect`:return i.length?i:null;case`sum`:return i.reduce((e,t)=>e+Number(t),0);case`max`:return i.length?i.reduce((e,t)=>Uz(t,e)>0?t:e):null;case`min`:return i.length?i.reduce((e,t)=>Uz(t,e)<0?t:e):null;default:throw wz(`the aggregate ${t.name}`,e.cypher)}},CB=e=>{let t=new Set,n=[];for(let r of e){let e=bB(r);t.has(e)||(t.add(e),n.push(r))}return n},wB=(e,t,n)=>{switch(n.kind){case`literal`:return n.value;case`param`:if(!(n.name in e.params))throw new Cz(`run`,`no parameter $${n.name} was given`,e.cypher);return e.params[n.name]??null;case`variable`:{let e=t.get(n.name);return e?e.kind===`value`?e.value:e.kind===`node`?`node#${e.node.seq}`:`edge#${e.edge.seq}`:null}case`property`:{if(n.target.kind===`variable`){let e=t.get(n.target.name);if(!e)return null;if(e.kind===`node`)return Fz(e.node.props[n.name]??null);if(e.kind===`edge`)return Fz(e.edge.props[n.name]??null);let r=e.value;return typeof r==`object`&&r&&!Array.isArray(r)&&!(r instanceof Date)?Fz(r[n.name]??null):null}let r=wB(e,t,n.target);return typeof r==`object`&&r&&!Array.isArray(r)&&!(r instanceof Date)?Fz(r[n.name]??null):null}case`list`:return n.items.map(n=>wB(e,t,n));case`struct`:{let r={};for(let i of n.entries)r[i.name]=wB(e,t,i.value);return r}case`cast`:return EB(e,wB(e,t,n.value),n);case`case`:for(let r of n.whens)if(wB(e,t,r.when)===!0)return wB(e,t,r.then);return n.otherwise?wB(e,t,n.otherwise):null;case`not`:{let r=wB(e,t,n.value);return r===null?null:r!==!0}case`and`:{let r=wB(e,t,n.left);if(r===!1)return!1;let i=wB(e,t,n.right);return i===!1?!1:r===null||i===null?null:!0}case`or`:{let r=wB(e,t,n.left);if(r===!0)return!0;let i=wB(e,t,n.right);return i===!0?!0:r===null||i===null?null:!1}case`compare`:return TB(e,t,n);case`in`:{let r=wB(e,t,n.value),i=wB(e,t,n.list);if(i===null||!Array.isArray(i)||r===null)return null;let a=!1;for(let e of i){let t=zz(r,e);if(t===!0)return!0;t===null&&(a=!0)}return a?null:!1}case`startsWith`:{let r=wB(e,t,n.value),i=wB(e,t,n.prefix);return typeof r!=`string`||typeof i!=`string`?null:r.startsWith(i)}case`isNull`:{let r=wB(e,t,n.value);return n.negated?r!==null:r===null}case`exists`:{let r=[t];for(let t of n.pattern)r=r.flatMap(n=>tB(e,n,t));let i=n.where?r.filter(t=>wB(e,t,n.where)===!0):r;return n.negated?i.length===0:i.length>0}case`call`:return DB(e,t,n)}},TB=(e,t,n)=>{let r=wB(e,t,n.left),i=wB(e,t,n.right);if(n.op===`=`)return zz(r,i);if(n.op===`<>`){let e=zz(r,i);return e===null?null:!e}if(r===null||i===null)return null;let a=Uz(r,i);switch(n.op){case`<`:return a<0;case`<=`:return a<=0;case`>`:return a>0;case`>=`:return a>=0}},EB=(e,t,n)=>Wz(t,n.to,e.cypher),DB=(e,t,n)=>{let r=n.args.map(n=>wB(e,t,n));switch(n.name){case`coalesce`:return r.find(e=>e!==null)??null;case`size`:{let e=r[0];return e==null?null:Array.isArray(e)||typeof e==`string`?e.length:null}case`current_timestamp`:return new Date;case`string_split`:{let[e,t]=r;if(typeof e!=`string`||typeof t!=`string`)return null;let n=e.split(t);return n.length?n:null}case`map`:{let[e,t]=r;if(!Array.isArray(e)||!Array.isArray(t))return null;let n={};return e.forEach((e,r)=>{n[String(e)]=t[r]??null}),n}case`json_extract`:{let[e,t]=r;if(typeof e!=`string`||typeof t!=`string`)return null;try{let n=JSON.parse(e),r=t.replace(/^\$\.?/,``);if(!r)return e;if(typeof n!=`object`||!n||Array.isArray(n))return null;let i=n[r];return i===void 0?null:JSON.stringify(i)}catch{return null}}default:throw hB.has(n.name)?wz(`the aggregate ${n.name} outside RETURN`,e.cypher):wz(`the function ${n.name}`,e.cypher)}},OB=e=>{let t=[],n=0,r=t=>{throw new Cz(`parse`,`${t} at ${n}`,e)};for(;n<e.length;){let i=e[n];if(kB.test(i)){n+=1;continue}if(i===`/`&&e[n+1]===`/`){for(;n<e.length&&e[n]!==`
1266
+ `;)n+=1;continue}if(i===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);t<0&&r(`an unterminated block comment`),n=t+2;continue}let a=n;if(i===`'`||i===`"`){n+=1;let o=``;for(;;){n>=e.length&&r(`an unterminated string that opened at ${a}`);let t=e[n];if(t===i){n+=1;break}if(t===`\\`){let t=e[n+1];t===void 0&&r(`an unterminated string that opened at ${a}`),o+=FB[t]??t,n+=2;continue}o+=t,n+=1}t.push({kind:`string`,text:o,upper:o,start:a,end:n});continue}if(AB.test(i)){for(;n<e.length&&AB.test(e[n]);)n+=1;if(e[n]===`.`&&AB.test(e[n+1]??``))for(n+=1;n<e.length&&AB.test(e[n]);)n+=1;let r=e.slice(a,n);t.push({kind:`number`,text:r,upper:r,start:a,end:n});continue}if(jB.test(i)){for(n+=1;n<e.length&&MB.test(e[n]);)n+=1;let r=e.slice(a,n);t.push({kind:`word`,text:r,upper:r.toUpperCase(),start:a,end:n});continue}if(i===`$`){n+=1;let i=n;for(;n<e.length&&MB.test(e[n]);)n+=1;n===i&&r(`a $ with no parameter name after it`);let o=e.slice(i,n);t.push({kind:`param`,text:o,upper:o.toUpperCase(),start:a,end:n});continue}let o=e.slice(n,n+2);if(NB.includes(o)){n+=2,t.push({kind:`symbol`,text:o,upper:o,start:a,end:n});continue}if(PB.includes(i)){n+=1,t.push({kind:`symbol`,text:i,upper:i,start:a,end:n});continue}r(`the character ${JSON.stringify(i)} cannot start a token`)}return t.push({kind:`end`,text:``,upper:``,start:e.length,end:e.length}),t},kB=/\s/,AB=/[0-9]/,jB=/[A-Za-z_]/,MB=/[A-Za-z0-9_]/,NB=[`->`,`<-`,`<=`,`>=`,`<>`,`..`],PB=`()[]{},.:|=<>*-+/%;`,FB={n:`
1267
+ `,t:` `,r:`\r`,b:`\b`,f:`\f`,"\\":`\\`,"'":`'`,'"':`"`},IB=e=>{let t={statement:e,tokens:OB(e),index:0},n=YB(t);return LB(t).kind!==`end`&&JB(t),n},LB=(e,t=0)=>e.tokens[Math.min(e.index+t,e.tokens.length-1)],RB=e=>{let t=LB(e);return t.kind!==`end`&&(e.index+=1),t},zB=(e,t,n=0)=>{let r=LB(e,n);return r.kind===`word`&&r.upper===t},BB=(e,t,n=0)=>{let r=LB(e,n);return r.kind===`symbol`&&r.text===t},VB=(e,t)=>zB(e,t)?(e.index+=1,!0):!1,HB=(e,t)=>BB(e,t)?(e.index+=1,!0):!1,UB=(e,t,n)=>{VB(e,t)||KB(e,`expected ${t} ${n}`)},WB=(e,t,n)=>{HB(e,t)||KB(e,`expected ${t} ${n}`)},GB=(e,t)=>{let n=LB(e);return n.kind!==`word`&&KB(e,`expected ${t}`),e.index+=1,n.text},KB=(e,t)=>{let n=LB(e);throw new Cz(`parse`,`${t}, saw ${n.kind===`end`?`the end of the statement`:JSON.stringify(e.statement.slice(n.start,n.end))} at ${n.start}`,e.statement)},qB=new Set([`ALTER`,`ATTACH`,`CALL`,`COPY`,`DROP`,`EXPORT`,`FOREACH`,`IMPORT`,`INSTALL`,`LOAD`,`REMOVE`,`SKIP`,`UNION`,`USE`]),JB=e=>{let t=LB(e);if(t.kind===`symbol`&&t.text===`;`)throw wz(`several statements in one string`,e.statement);if(t.kind===`word`&&qB.has(t.upper))throw wz(`the ${t.upper} clause`,e.statement);return KB(e,`expected the end of the statement`)},YB=e=>zB(e,`CREATE`)&&(zB(e,`NODE`,1)||zB(e,`REL`,1))?ZB(e):zB(e,`CALL`)?XB(e):eV(e),XB=e=>{RB(e);let t=GB(e,`a procedure name after CALL`);if(t.toLowerCase()!==`show_tables`)throw wz(`CALL ${t}()`,e.statement);return WB(e,`(`,`after show_tables`),WB(e,`)`,`after show_tables(`),UB(e,`RETURN`,`after CALL show_tables()`),WB(e,`*`,`after RETURN, which is the only projection show_tables takes`),{kind:`showTables`}},ZB=e=>{RB(e);let t=VB(e,`NODE`);t||UB(e,`REL`,`after CREATE, to say which kind of table`),UB(e,`TABLE`,`after CREATE ${t?`NODE`:`REL`}`);let n=!1;VB(e,`IF`)&&(UB(e,`NOT`,`after IF`),UB(e,`EXISTS`,`after IF NOT`),n=!0);let r=GB(e,`a table name`);WB(e,`(`,`to open the table body`);let i=[],a=[];if(!BB(e,`)`))do{if(zB(e,`FROM`)&&zB(e,`TO`,2)){RB(e);let t=GB(e,`the FROM table`);UB(e,`TO`,`after the FROM table`),i.push({from:t,to:GB(e,`the TO table`)});continue}a.push(QB(e))}while(HB(e,`,`));return WB(e,`)`,`to close the table body`),t?(i.length&&KB(e,`a node table cannot declare FROM ... TO`),{kind:`createNodeTable`,name:r,ifNotExists:n,columns:a}):(i.length||KB(e,`a rel table must declare at least one FROM ... TO`),{kind:`createRelTable`,name:r,ifNotExists:n,pairs:i,columns:a})},QB=e=>{let t=GB(e,`a column name`),n=$B(e),r=!1;zB(e,`PRIMARY`)&&(RB(e),UB(e,`KEY`,`after PRIMARY`),r=!0);let i=VB(e,`DEFAULT`)?vV(e):void 0;return{name:t,type:n,primaryKey:r,defaultTo:i}},$B=e=>{let t=LB(e);t.kind!==`word`&&KB(e,`expected a column type`),e.index+=1;let n;switch(t.upper){case`STRING`:n={kind:`STRING`};break;case`INT64`:n={kind:`INT64`};break;case`DOUBLE`:n={kind:`DOUBLE`};break;case`BOOLEAN`:n={kind:`BOOLEAN`};break;case`JSON`:n={kind:`JSON`};break;case`TIMESTAMP`:n={kind:`TIMESTAMP`};break;case`MAP`:{WB(e,`(`,`after MAP`);let t=$B(e);WB(e,`,`,`between the MAP key type and its value type`);let r=$B(e);WB(e,`)`,`to close MAP(`),n={kind:`MAP`,key:t,value:r};break}default:throw wz(`the column type ${t.text}`,e.statement)}for(;BB(e,`[`)&&BB(e,`]`,1);)e.index+=2,n={kind:`LIST`,of:n};return n},eV=e=>{let t=[],n=[],r,i=r=>{if(n.length)throw wz(`a reading clause after an updating clause`,e.statement);t.push(r)};for(;;){let t=LB(e);if(t.kind!==`word`)break;if(t.upper===`UNWIND`){i(tV(e));continue}if(t.upper===`MATCH`||t.upper===`OPTIONAL`&&zB(e,`MATCH`,1)){i(nV(e));continue}if(t.upper===`WITH`){i(rV(e));continue}if(t.upper===`CREATE`){n.push(iV(e));continue}if(t.upper===`MERGE`){n.push(aV(e));continue}if(t.upper===`SET`){n.push(oV(e));continue}if(t.upper===`DELETE`||t.upper===`DETACH`&&zB(e,`DELETE`,1)){n.push(lV(e));continue}t.upper===`RETURN`&&(r=uV(e));break}if(!t.length&&!n.length&&!r){let t=LB(e);if(t.kind===`word`&&qB.has(t.upper))throw wz(`the ${t.upper} clause`,e.statement);KB(e,`expected a statement`)}return{kind:`query`,reading:t,updating:n,returning:r}},tV=e=>{RB(e);let t=vV(e);return UB(e,`AS`,`after the UNWIND source`),{kind:`unwind`,source:t,as:GB(e,`a variable after AS`)}},nV=e=>{let t=VB(e,`OPTIONAL`);UB(e,`MATCH`,t?`after OPTIONAL`:`to open a match`);let n=[fV(e)];for(;HB(e,`,`);)n.push(fV(e));return{kind:`match`,optional:t,patterns:n,where:VB(e,`WHERE`)?vV(e):void 0}},rV=e=>{if(RB(e),zB(e,`DISTINCT`))throw wz(`WITH DISTINCT`,e.statement);let t=[dV(e)];for(;HB(e,`,`);)t.push(dV(e));if(zB(e,`ORDER`))throw wz(`ORDER BY in a WITH clause`,e.statement);return{kind:`with`,items:t,where:VB(e,`WHERE`)?vV(e):void 0}},iV=e=>{RB(e);let t=[fV(e)];for(;HB(e,`,`);)t.push(fV(e));return{kind:`create`,patterns:t}},aV=e=>{RB(e);let t=pV(e);if(BB(e,`-`)||BB(e,`<-`))throw wz(`MERGE of a relationship pattern`,e.statement);let n=[],r=[];for(;zB(e,`ON`);){RB(e);let t=VB(e,`CREATE`)?n:VB(e,`MATCH`)?r:KB(e,`expected CREATE or MATCH after ON`);UB(e,`SET`,`after ON CREATE / ON MATCH`),t.push(...sV(e))}return{kind:`merge`,node:t,onCreate:n,onMatch:r}},oV=e=>(RB(e),{kind:`set`,assignments:sV(e)}),sV=e=>{let t=[cV(e)];for(;HB(e,`,`);)t.push(cV(e));return t},cV=e=>{let t=wV(e);return t.kind!==`property`&&t.kind!==`variable`&&KB(e,`expected a variable or a property on the left of =`),WB(e,`=`,`in an assignment`),{target:t,value:vV(e)}},lV=e=>{let t=VB(e,`DETACH`);UB(e,`DELETE`,t?`after DETACH`:`to open a delete`);let n=[wV(e)];for(;HB(e,`,`);)n.push(wV(e));return{kind:`delete`,targets:n,detach:t}},uV=e=>{RB(e);let t=VB(e,`DISTINCT`);if(BB(e,`*`))throw wz(`RETURN *`,e.statement);let n=[dV(e)];for(;HB(e,`,`);)n.push(dV(e));let r=[];if(VB(e,`ORDER`)){UB(e,`BY`,`after ORDER`);do{let t=vV(e),n=VB(e,`DESC`);n||VB(e,`ASC`),r.push({value:t,descending:n})}while(HB(e,`,`))}let i;if(VB(e,`LIMIT`)){let t=LB(e);if(t.kind!==`number`)throw wz(`LIMIT with anything but a number`,e.statement);e.index+=1,i=Number(t.text)}return{distinct:t,items:n,orderBy:r,limit:i}},dV=e=>{let t=LB(e).start,n=vV(e),r=e.tokens[e.index-1]?.end??t;return VB(e,`AS`)?{value:n,as:GB(e,`an alias after AS`)}:{value:n,as:e.statement.slice(t,r)}},fV=e=>{let t=pV(e),n=[];for(;BB(e,`-`)||BB(e,`<-`);){let t=mV(e);n.push({rel:t,node:pV(e)})}return{start:t,steps:n}},pV=e=>{WB(e,`(`,`to open a node pattern`);let t=LB(e).kind===`word`?GB(e,`a variable`):void 0,n;if(HB(e,`:`)&&(n=GB(e,`a label after :`),BB(e,`:`)))throw wz(`a node pattern with several labels`,e.statement);let r=BB(e,`{`)?gV(e):[];return WB(e,`)`,`to close a node pattern`),{variable:t,label:n,properties:r}},mV=e=>{let t=HB(e,`<-`);t||WB(e,`-`,`to open a relationship pattern`),WB(e,`[`,`after -, since every relationship in this subset is written -[...]-`);let n=LB(e).kind===`word`?GB(e,`a variable`):void 0,r;if(HB(e,`:`)&&(r=GB(e,`a relationship type after :`),BB(e,`|`)))throw wz(`a relationship pattern with several types`,e.statement);let i=BB(e,`*`)?hV(e):void 0,a=BB(e,`{`)?gV(e):[];WB(e,`]`,`to close a relationship pattern`);let o=HB(e,`->`);return o||WB(e,`-`,`to close a relationship pattern`),t&&o&&KB(e,`a relationship cannot point both ways`),{variable:n,type:r,direction:t?`left`:o?`right`:`undirected`,properties:a,range:i}},hV=e=>{RB(e);let t=LB(e);t.kind!==`number`&&KB(e,`expected a lower bound after * in a variable length relationship`),e.index+=1;let n=Number(t.text),r=n;if(HB(e,`..`)){let t=LB(e);if(t.kind!==`number`)throw wz(`a variable length relationship with no upper bound`,e.statement);e.index+=1,r=Number(t.text)}let i,a,o;return HB(e,`(`)&&(a=GB(e,`the relationship variable of a variable length filter`),WB(e,`,`,`between the two variables of a variable length filter`),o=GB(e,`the node variable of a variable length filter`),WB(e,`|`,`after the variables of a variable length filter`),UB(e,`WHERE`,`to open a variable length filter`),i=vV(e),WB(e,`)`,`to close a variable length filter`)),{min:n,max:r,relVariable:a,nodeVariable:o,filter:i}},gV=e=>{WB(e,`{`,`to open a property map`);let t=[];if(!BB(e,`}`))do{let n=GB(e,`a property name`);WB(e,`:`,`after a property name`),t.push({name:n,value:vV(e)})}while(HB(e,`,`));return WB(e,`}`,`to close a property map`),t},_V=new Set([`+`,`-`,`*`,`/`,`%`]),vV=e=>{let t=yV(e),n=LB(e);if(n.kind===`symbol`&&_V.has(n.text))throw wz(`arithmetic (${n.text}) in an expression`,e.statement);return t},yV=e=>{let t=bV(e);for(;VB(e,`OR`);)t={kind:`or`,left:t,right:bV(e)};if(zB(e,`XOR`))throw wz(`XOR`,e.statement);return t},bV=e=>{let t=xV(e);for(;VB(e,`AND`);)t={kind:`and`,left:t,right:xV(e)};return t},xV=e=>zB(e,`NOT`)?zB(e,`EXISTS`,1)?(e.index+=2,OV(e,!0)):(RB(e),{kind:`not`,value:xV(e)}):CV(e),SV={"=":`=`,"<>":`<>`,"<":`<`,"<=":`<=`,">":`>`,">=":`>=`},CV=e=>{let t=wV(e);if(zB(e,`IS`)){RB(e);let n=VB(e,`NOT`);return UB(e,`NULL`,n?`after IS NOT`:`after IS`),{kind:`isNull`,value:t,negated:n}}if(VB(e,`IN`))return{kind:`in`,value:t,list:wV(e)};if(zB(e,`STARTS`))return RB(e),UB(e,`WITH`,`after STARTS`),{kind:`startsWith`,value:t,prefix:wV(e)};if(zB(e,`ENDS`))throw wz(`ENDS WITH`,e.statement);if(zB(e,`CONTAINS`))throw wz(`CONTAINS`,e.statement);let n=LB(e),r=n.kind===`symbol`?SV[n.text]:void 0;return r?(e.index+=1,{kind:`compare`,op:r,left:t,right:wV(e)}):t},wV=e=>{let t=TV(e);for(;HB(e,`.`);)t={kind:`property`,target:t,name:GB(e,`a property name after .`)};return t},TV=e=>{let t=LB(e);if(t.kind===`number`)return e.index+=1,{kind:`literal`,value:Number(t.text)};if(t.kind===`string`)return e.index+=1,{kind:`literal`,value:t.text};if(t.kind===`param`)return e.index+=1,{kind:`param`,name:t.text};if(t.kind===`symbol`){if(t.text===`(`){e.index+=1;let t=vV(e);return WB(e,`)`,`to close a parenthesised expression`),t}if(t.text===`[`){e.index+=1;let t=[];if(!BB(e,`]`))do t.push(vV(e));while(HB(e,`,`));return WB(e,`]`,`to close a list`),{kind:`list`,items:t}}if(t.text===`{`)return{kind:`struct`,entries:gV(e)};if(t.text===`-`){let t=LB(e,1);return t.kind!==`number`&&KB(e,`expected an expression`),e.index+=2,{kind:`literal`,value:-Number(t.text)}}return KB(e,`expected an expression`)}if(t.kind===`word`){switch(t.upper){case`TRUE`:return e.index+=1,{kind:`literal`,value:!0};case`FALSE`:return e.index+=1,{kind:`literal`,value:!1};case`NULL`:return e.index+=1,{kind:`literal`,value:null};case`CASE`:return DV(e);case`EXISTS`:return e.index+=1,OV(e,!1);default:break}return BB(e,`(`,1)?EV(e):(e.index+=1,{kind:`variable`,name:t.text})}return KB(e,`expected an expression`)},EV=e=>{let t=GB(e,`a function name`).toLowerCase();if(WB(e,`(`,`after a function name`),t===`cast`){let t=vV(e);UB(e,`AS`,`inside cast(...)`);let n=$B(e);return WB(e,`)`,`to close cast(`),{kind:`cast`,value:t,to:n}}let n=!1,r=!1,i=[];if(HB(e,`*`))n=!0;else if(!BB(e,`)`)){r=VB(e,`DISTINCT`);do i.push(vV(e));while(HB(e,`,`))}return WB(e,`)`,`to close ${t}(`),{kind:`call`,name:t,args:i,distinct:r,star:n}},DV=e=>{if(RB(e),!zB(e,`WHEN`))throw wz(`CASE over a value (CASE x WHEN ...)`,e.statement);let t=[];for(;VB(e,`WHEN`);){let n=vV(e);UB(e,`THEN`,`after a CASE condition`),t.push({when:n,then:vV(e)})}let n=VB(e,`ELSE`)?vV(e):void 0;return UB(e,`END`,`to close CASE`),{kind:`case`,whens:t,otherwise:n}},OV=(e,t)=>{if(BB(e,`(`))throw wz(`EXISTS over an expression`,e.statement);if(WB(e,`{`,`to open an EXISTS subquery`),zB(e,`OPTIONAL`))throw wz(`OPTIONAL MATCH in a subquery`,e.statement);UB(e,`MATCH`,`inside an EXISTS subquery, which holds one MATCH and nothing else`);let n=[fV(e)];for(;HB(e,`,`);)n.push(fV(e));let r=VB(e,`WHERE`)?vV(e):void 0;return WB(e,`}`,`to close an EXISTS subquery`),{kind:`exists`,pattern:n,where:r,negated:t}},kV=()=>{let e=new jz,t=new Map,n=n=>{let r=t.get(n);if(r)return r;let i=IB(n);return i.kind===`query`&&Az(e,i,n),t.size>=500&&t.delete(t.keys().next().value),t.set(n,i),i},r=(t,r)=>{let i=n(t);switch(i.kind){case`createNodeTable`:return Dz(e,i,t);case`createRelTable`:return Oz(e,i,t);case`showTables`:return kz(e);case`query`:return e.transact(()=>Gz({store:e,params:r,cypher:t},i))}};return{query:async(e,t={})=>{try{return r(e,t)}catch(t){let n=t instanceof Error?t.message:String(t);throw new Cz(t instanceof Cz?t.phase:`run`,`${n} (statement: ${e.slice(0,120)})`,e)}},tables:()=>e.all().map(e=>({name:e.name,kind:e.kind})),close:()=>{t.clear()}}},AV=/\b(CREATE|MERGE|SET|DELETE|DETACH|DROP|ALTER|COPY|INSTALL|LOAD)\b/i,jV=[],MV=e=>{jV.push(e)},NV=e=>{if(AV.test(e))for(let e of jV)e()};let PV;const FV=async()=>{let e=kV();return{query:async(t,n)=>{let r=await e.query(t,n);return NV(t),r},version:`cypher-store`}},IV=()=>PV??=FV();let LV=!1;const RV=e=>{LV=e},zV=()=>LV,BV=new Set([`_id`]),VV=e=>{if(Array.isArray(e))return e.map(VV);if(typeof e!=`object`||!e)return e;let t=Object.keys(e).filter(e=>!BV.has(e)).sort().map(t=>[t,VV(e[t])]);return Object.fromEntries(t)},HV=e=>JSON.stringify(VV(e)),UV=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),WV=async e=>UV(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e))),GV=e=>WV(HV(e)),KV=[`CREATE NODE TABLE IF NOT EXISTS Origin(
1268
+ id STRING PRIMARY KEY,
1269
+ raw JSON, // the Origin row as the resolver returned it
1270
+ hash STRING, seq INT64
1271
+ )`,`CREATE NODE TABLE IF NOT EXISTS Media(
1272
+ uri STRING PRIMARY KEY,
1273
+ origin STRING, // 'mal', 'cr', 'nf' ... the ORIGIN, not the module
1274
+ id STRING,
1275
+ owned BOOLEAN, // true once the origin's own resolver described this uri; false = placeholder
1276
+ scope STRING, // the OWNER'S last word: RUN, CONTAINER or NULL
1277
+ raw JSON, // the owner's field-merged row (4.3): a projection of the Answer log
1278
+ score DOUBLE, // verbatim projections of raw, so a WHERE clause can read them
1279
+ episodeCount INT64, startDate STRING, endDate STRING, type STRING, status STRING,
1280
+ season STRING, seasonYear INT64, titles JSON, categories STRING[],
1281
+ fieldSeq MAP(STRING, INT64), // field name -> Answer.seq that supplied the current value
1282
+ hash STRING, // content hash of the merged row, re-checked by the audit (5.3)
1283
+ seq INT64
1284
+ )`,`CREATE NODE TABLE IF NOT EXISTS Episode(
1285
+ uri STRING PRIMARY KEY,
1286
+ origin STRING, id STRING,
1287
+ mediaUri STRING, // the uri the source hung it on, as returned
1288
+ raw JSON,
1289
+ episodeNumber INT64, seasonNumber INT64, absoluteEpisodeNumber INT64, // the SOURCE'S numbering space
1290
+ releaseDate STRING, // as returned: an instant or a named day
1291
+ titles JSON,
1292
+ fieldSeq MAP(STRING, INT64),
1293
+ hash STRING, seq INT64
1294
+ )`,`CREATE NODE TABLE IF NOT EXISTS Answer(
1295
+ key STRING PRIMARY KEY, // sha-256 over (origin, kind, uri, canonical JSON of raw)
1296
+ seq INT64, // ingest sequence, monotonic, assigned when the key is first seen
1297
+ uri STRING, origin STRING,
1298
+ kind STRING, // 'media' | 'episode' | 'origin'
1299
+ operation STRING, // the root operation the request carried
1300
+ selection STRING[], // the field names the answer carried, so a partial answer is visible as such
1301
+ raw JSON, // the resolver's return value, byte for byte, handles and episodes included
1302
+ at TIMESTAMP DEFAULT current_timestamp()
1303
+ )`,`CREATE NODE TABLE IF NOT EXISTS Ask(
1304
+ key STRING PRIMARY KEY, // sha-256 over (clusterId, origin, showId, questionHash, seq)
1305
+ runUri STRING, clusterId STRING, origin STRING, showId STRING,
1306
+ questionHash STRING, // the normalised SimilarMediaInput
1307
+ outcome STRING, // 'answered' | 'containing' | 'refused' | 'declined' | 'refused-by-title' | 'refused-other-run'
1308
+ reason STRING, // SimilarOutcome's reason (src/sources/similar.ts:51-52)
1309
+ answerUri STRING, seq INT64
1310
+ )`],qV=[`CREATE REL TABLE IF NOT EXISTS CLAIMS(FROM Media TO Media,
1311
+ key STRING, // sha-256 over (from, to, kind, claimer, provenance)
1312
+ kind STRING, // 'SAME_AS' | 'PART_OF' | 'INCLUDES'
1313
+ provenance STRING, // 'source' | 'ask' | 'seed' | 'address'
1314
+ claimer STRING, // the origin whose resolver returned the handle
1315
+ targetScope STRING, // the scope stamped on the nested node, or NULL
1316
+ node JSON, // the nested node as returned: the claimer's DESCRIPTION of the target
1317
+ hash STRING, // content hash of node, re-checked by the audit (5.3)
1318
+ answerSeq INT64, seq INT64)`,`CREATE REL TABLE IF NOT EXISTS HAS_EPISODE(FROM Media TO Episode,
1319
+ key STRING, // sha-256 over (from, to, claimer)
1320
+ claimer STRING, answerSeq INT64, seq INT64)`,`CREATE REL TABLE IF NOT EXISTS EPISODE_CLAIMS(FROM Episode TO Episode,
1321
+ key STRING, kind STRING, provenance STRING, claimer STRING, node JSON, answerSeq INT64, seq INT64)`,`CREATE REL TABLE IF NOT EXISTS RELATED(FROM Media TO Media,
1322
+ relation STRING, format STRING, claimer STRING, node JSON, answerSeq INT64)`,`CREATE REL TABLE IF NOT EXISTS ABOUT(FROM Answer TO Media, FROM Answer TO Episode, FROM Answer TO Origin)`],JV=[`CREATE NODE TABLE IF NOT EXISTS MediaProfile(
1323
+ uri STRING PRIMARY KEY, by STRING, version INT64,
1324
+ scope STRING, // the EFFECTIVE scope, the ratchet computed as a view (5.4 P0)
1325
+ scopeFrom STRING[], // which answers or claims said CONTAINER
1326
+ dateSubject STRING, // 'run' | 'container': what the row's dates date
1327
+ titleKeys JSON, // [{key, score, language, class}]
1328
+ titleKeysFolded JSON, // the same after NFD with combining marks removed
1329
+ seasonOrdinal INT64, partOrdinal INT64, ordinalFrom STRING, // parsed from RAW titles; NULL = silent
1330
+ year INT64, startDay INT64, // startDay is a UTC day number; NULL when the precision is not a day
1331
+ datePrecision STRING, // 'day' | 'month-or-year' | 'none'
1332
+ dateDerivation STRING, // 'published' | 'coerced' | 'declared'
1333
+ format STRING, workKind STRING, companion BOOLEAN,
1334
+ countKind STRING, // 'declared' | 'listLength' | 'none'
1335
+ countStated INT64, // the source's own figure
1336
+ countDistinct INT64, // count(DISTINCT HAS_EPISODE targets) when a list exists, else NULL
1337
+ folding BOOLEAN, // origin folds cours into seasons: cr, nf, jw
1338
+ retranslates BOOLEAN, // origin commissions its own episode titles: nf
1339
+ showLevelOrigin BOOLEAN, // every id of this origin names a container
1340
+ idParent STRING // the same-origin prefix parent of this id, when one exists
1341
+ )`,`CREATE NODE TABLE IF NOT EXISTS EpisodeProfile(
1342
+ uri STRING PRIMARY KEY, by STRING, version INT64,
1343
+ day INT64, // UTC day of releaseDate (consensus.ts:85-88)
1344
+ dayPrecision STRING, // 'instant' | 'day' | 'none'
1345
+ numberSpace STRING, // 'entry' | 'season' | 'position'
1346
+ titleKeys JSON,
1347
+ synopsisKeys JSON, // [{key, score, language}]: the synopsis as content words (5.4 P4 rule 3)
1348
+ generic BOOLEAN // 'Episode 13' carries no identity
1349
+ )`,`CREATE NODE TABLE IF NOT EXISTS TitleKey(key STRING PRIMARY KEY, by STRING, version INT64)`,`CREATE NODE TABLE IF NOT EXISTS Cluster(
1350
+ id STRING PRIMARY KEY, // the Media._id the app caches on; minted once, carried across growth
1351
+ by STRING, version INT64,
1352
+ scope STRING, // 'RUN' | 'CONTAINER'
1353
+ key STRING, // lowest member uri
1354
+ published STRING[], // every routable member uri ever published under this id: append-only
1355
+ aggUri STRING, // 'ag:(' + sorted published uris + ')'
1356
+ aliases STRING[], // ids retired into this cluster
1357
+ hidden BOOLEAN, // the listing hide rule (6.1), written false explicitly, never left unset
1358
+ hiddenBy STRING[], // the run cluster ids the hide rule found
1359
+ kind STRING, // 'RUN' | 'CONTAINER' | 'FOLD' (6.5): which page is drawn, never the visibility
1360
+ runLength INT64, runLengthTier DOUBLE, runLengthWitnesses INT64, runLengthFrom STRING[],
1361
+ preferredRun STRING, // a container cluster's earliest attached run cluster id
1362
+ card JSON, // the listing's fields (6.1)
1363
+ media JSON, // the full aggregated Media with provenance (6.3)
1364
+ episodes JSON, // the ordered episode list, one entry per Slot (6.4)
1365
+ anomalies JSON, // [{rule, detail}]
1366
+ anomalyCount INT64 // tested by the trace, because size() over a JSON column is a string length
1367
+ )`,`CREATE NODE TABLE IF NOT EXISTS Alias(id STRING PRIMARY KEY, clusterId STRING, by STRING, version INT64)`,`CREATE NODE TABLE IF NOT EXISTS Slot(
1368
+ id STRING PRIMARY KEY, // '<clusterId>#<number>', or '<clusterId>#s:<lowest uri>' for a special
1369
+ by STRING, version INT64, clusterId STRING, number INT64,
1370
+ episode JSON // the aggregated Episode with provenance (6.4)
1371
+ )`],YV=[`CREATE REL TABLE IF NOT EXISTS LINK(FROM Media TO Media,
1372
+ key STRING, // sha-256 over (from, to, kind, by): the writer's diff key
1373
+ kind STRING, // 'SAME_AS' | 'PART_OF' | 'INCLUDES'
1374
+ by STRING, version INT64,
1375
+ status STRING, // 'active' | 'refused' (a refused proposal is kept, with its reason)
1376
+ reason STRING, confidence DOUBLE, evidence JSON,
1377
+ gates JSON, // {format, season, date, companion}: 'passed' | 'refused' | 'silent'
1378
+ fromStart INT64, fromEnd INT64, toStart INT64, toEnd INT64, // INCLUDES only (section 3.4)
1379
+ contiguous BOOLEAN, aligned INT64, total INT64,
1380
+ supports STRING[]) // keys of the CLAIMS / LINK / EPISODE_LINK edges it was derived from`,`CREATE REL TABLE IF NOT EXISTS EPISODE_LINK(FROM Episode TO Episode,
1381
+ key STRING, // sha-256 over (from, to, by)
1382
+ kind STRING, // 'SAME_AS'
1383
+ by STRING, version INT64, status STRING, reason STRING, confidence DOUBLE, evidence JSON,
1384
+ fromNumber INT64, toNumber INT64, // the two rows' own numbers, so a renumbering is readable off the edge
1385
+ supports STRING[])`,`CREATE REL TABLE IF NOT EXISTS PROFILE_OF(FROM MediaProfile TO Media, FROM EpisodeProfile TO Episode, by STRING)`,`CREATE REL TABLE IF NOT EXISTS HAS_KEY(FROM Media TO TitleKey, key STRING, by STRING, version INT64, score DOUBLE, language STRING, class STRING)`,`CREATE REL TABLE IF NOT EXISTS MEMBER_OF(FROM Media TO Cluster, by STRING, version INT64, via STRING)`,`CREATE REL TABLE IF NOT EXISTS ATTACHED_TO(FROM Cluster TO Cluster, by STRING, version INT64, via STRING, supports STRING[])`,`CREATE REL TABLE IF NOT EXISTS SLOT_OF(FROM Slot TO Cluster, by STRING)`,`CREATE REL TABLE IF NOT EXISTS FILLS(FROM Episode TO Slot, by STRING, version INT64, via STRING, number INT64, supports STRING[])`],XV=[...KV,...JV,...qV,...YV],ZV=e=>e.match(/CREATE (?:NODE|REL) TABLE IF NOT EXISTS (\w+)/)?.[1]??``,QV=XV.map(ZV),$V=[...KV,...JV].map(ZV),eH=[...qV,...YV].map(ZV),tH=async({query:e})=>{for(let t of XV)await e(t)};let nH;const rH=async()=>{let e=await IV();return nH?.graph!==e&&(nH={graph:e,done:tH(e)}),await nH.done,e},iH={media:`Media`,similarMedia:`Media`,containingMedia:`Media`,"mediaPage.nodes":`Media`,origin:`Origin`,"originPage.nodes":`Origin`,"media.episodes":`Episode`,"similarMedia.episodes":`Episode`,"containingMedia.episodes":`Episode`,"mediaPage.nodes.episodes":`Episode`},aH={Media:`media`,Episode:`episode`,Origin:`origin`},oH=e=>{let t=[];for(let n=e.path;n;n=n.prev)typeof n.key==`string`&&t.unshift(n.key);return t.join(`.`)},sH=(e,t)=>iH[oH(e)]===t?aH[t]:void 0,cH=(e,t,n,r)=>WV(`${e}\0${t}\0${n}\0${HV(r)}`);let lH;const uH=e=>{let t=lH;return lH=e,t},dH=e=>typeof e==`object`&&!!e&&!Array.isArray(e),fH=(e,t)=>{let n=e===`origin`?t.id:t.uri,r=e===`origin`?t.id:t.origin;if(!(typeof n!=`string`||!n||typeof r!=`string`||!r))return{uri:n,origin:r}},pH=async(e,t,n)=>{let r=fH(e,n);if(r)return{key:await cH(r.origin,e,r.uri,n),...r,kind:e,operation:t,selection:Object.keys(n).filter(e=>n[e]!==void 0).sort(),raw:JSON.stringify(n)}},mH=e=>{let t=e.variableValues?.input;return FA(t?.context?.token)?.operation??`UNKNOWN`};let hH=[],gH,_H,vH,yH=Promise.resolve(),bH=0;const xH=async e=>{if(!e.length)return;let{query:t}=await rH(),n=new Map;for(let t of e)n.has(t.key)||n.set(t.key,t);let r=await t(`UNWIND $keys AS k MATCH (a:Answer {key: k}) RETURN a.key AS key`,{keys:[...n.keys()]}),i=new Set(r.map(e=>e.key)),a=[...n.values()].filter(e=>!i.has(e.key)).map(e=>({...e,seq:++bH}));if(a.length){await t(`UNWIND $rows AS r
1386
+ CREATE (:Answer {key: r.key, seq: r.seq, uri: r.uri, origin: r.origin, kind: r.kind,
1387
+ operation: r.operation,
1388
+ selection: CASE WHEN r.selection = '' THEN cast(NULL AS STRING[]) ELSE string_split(r.selection, $separator) END,
1389
+ raw: r.raw})`,{separator:`\0`,rows:a.map(e=>({...e,selection:e.selection.join(`\0`)}))});try{await lH?.(a)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(Error(`graph: the ingest dropped a batch of ${a.length} answer(s): ${t}`,{cause:e}))}}},SH=()=>{gH!==void 0&&clearTimeout(gH);let e=_H;gH=void 0,_H=void 0,vH=void 0;let t=hH;return hH=[],yH=yH.then(()=>xH(t)).catch(e=>{console.error(Error(`graph: the answer log dropped ${t.length} row(s)`,{cause:e}))}).finally(()=>e?.()),yH},CH=()=>(vH??=new Promise(e=>{_H=e}),gH??=setTimeout(()=>{SH()},50),vH),wH=(e,t,n)=>{if(!zV())return;let r=sH(e,t);if(!r)return;let i=(Array.isArray(n)?n:[n]).filter(dH);if(!i.length)return;let a=mH(e);return Promise.all(i.map(e=>pH(r,a,e))).then(e=>{let t=e.filter(e=>e!==void 0);if(t.length)return hH.push(...t),CH()}).catch(e=>{console.error(Error(`graph: the answer log could not read a resolver return value`,{cause:e}))})},TH=async()=>{for(;hH.length||gH!==void 0;)await SH();await yH},EH=async()=>{if(!zV())throw Error(`graph: the answer log is off, load the page with ?graph=1`);await TH();let{query:e}=await rH();return(await e(`MATCH (a:Answer)
1390
+ RETURN a.key AS key, a.seq AS seq, a.uri AS uri, a.origin AS origin, a.kind AS kind,
1391
+ a.operation AS operation, a.selection AS selection, a.raw AS raw
1392
+ ORDER BY a.seq`)).map(e=>({...e,selection:e.selection??[]}))},DH=(e,t)=>e<t?-1:+(e>t),OH=e=>[...e].sort((e,t)=>(t.score??-1)-(e.score??-1)||DH(e.uri,t.uri)),kH=e=>typeof e==`object`&&!!e&&!Array.isArray(e),AH=e=>Array.isArray(e)?e:[],jH=e=>kH(e)&&typeof e.score==`number`?e.score:-1,MH=e=>[...e].sort((e,t)=>jH(t)-jH(e)),NH=e=>{let t=[];e.includes(`ANIME`)&&t.push(`ANIME`);let n=e.find(e=>e===`MOVIE`||e===`SERIES`);return n&&t.push(n),t},PH=e=>{let t=new Set,n=[];for(let r of e){let e=r.toLowerCase();!r||t.has(e)||(t.add(e),n.push(r))}return n},FH=(e,t)=>{let n=new Set,r=[];for(let i of t){let t=kH(i)?i[e]:i;n.has(t)||(n.add(t),r.push(i))}return r},IH=e=>AH(e).filter(e=>typeof e==`string`),LH=e=>{let t=e.filter(WS),n=[...t.length?t:e].sort();return{uri:`ag:(${n.join(`,`)})`,id:`(${n.join(`,`)})`}},RH=(e,t)=>{let n=e.indexOf(`:`);return{origin:typeof t.origin==`string`&&t.origin?t.origin:e.slice(0,Math.max(n,0)),id:typeof t.id==`string`&&t.id?t.id:e.slice(n+1)}},zH=e=>({...e.raw,_id:e.uri,uri:e.uri,origin:e.origin,id:e.id,handles:[],episodes:[]}),BH=[`url`,`type`,`status`,`averageScore`,`popularity`,`startDate`,`endDate`,`isAdult`,`nextAiringEpisode`],VH=e=>{let t=new Map;for(let n of[...e].sort((e,t)=>e.relation.localeCompare(t.relation)||e.uri.localeCompare(t.uri)||e.by.localeCompare(t.by)||e.via.localeCompare(t.via))){let e=`${n.relation}\u0000${n.uri}`;t.has(e)||t.set(e,n)}return[...t.values()]},HH=e=>{let{cluster:t,locationOrigin:n}=e,r=OH(e.members),i=r.filter(e=>e.owned),a=[],o=LH(r.map(e=>e.uri)),s={_id:t.id,uri:t.aggUri,id:o.id,origin:`ag`,url:`${n}/${qR(GR.MEDIA,{uri:t.aggUri}).replace(/^\//,``)}`,scope:t.scope,kind:t.scope,score:r.length?Math.max(...r.map(e=>e.score??0)):null,handles:[],episodes:[],provenance:a,anomalies:t.anomalies};for(let e of BH){let t=i.find(t=>t.raw[e]!==null&&t.raw[e]!==void 0);s[e]=t?t.raw[e]:null,t&&a.push({field:e,uri:t.uri,answerSeq:t.fieldSeq[e]??null,rule:`first-non-null`})}s.url=`${n}/${qR(GR.MEDIA,{uri:t.aggUri}).replace(/^\//,``)}`,s.episodeCount=t.runLength,a.push({field:`episodeCount`,uris:t.runLengthFrom,tier:t.runLengthTier,witnesses:t.runLengthWitnesses,rule:`tiered`});let c=i.find(e=>typeof e.raw.season==`string`&&e.raw.season),l=i.find(e=>e.raw.seasonYear!==null&&e.raw.seasonYear!==void 0);s.season=c?c.raw.season:null,s.seasonYear=(c?c.raw.seasonYear:l?.raw.seasonYear)??null,(c||l)&&a.push({field:`season`,uri:(c??l).uri,rule:`season-pair`});let u=i.flatMap(e=>IH(e.raw.categories));s.categories=NH(u),i.length&&a.push({field:`categories`,uri:i[0].uri,rule:`first-non-null`});for(let e of[`genres`,`tags`]){s[e]=PH(i.flatMap(t=>IH(t.raw[e])));for(let t of i)IH(t.raw[e]).length&&a.push({field:e,uri:t.uri,rule:`best-score`})}s.titles=FH(`title`,MH(i.flatMap(e=>AH(e.raw.titles))));for(let e of i)AH(e.raw.titles).length&&a.push({field:`titles`,uri:e.uri,answerSeq:e.fieldSeq.titles??null,rule:`concat`});for(let e of[`descriptions`,`shortDescriptions`,`covers`,`banners`]){s[e]=MH(i.flatMap(t=>AH(t.raw[e])));for(let t of i)AH(t.raw[e]).length&&a.push({field:e,uri:t.uri,answerSeq:t.fieldSeq[e]??null,rule:`concat`})}s.trailers=FH(`uri`,MH(i.flatMap(e=>AH(e.raw.trailers))));let d=i.find(e=>e.raw.franchise!==null&&e.raw.franchise!==void 0);s.franchise=d?d.raw.franchise:null,d&&a.push({field:`franchise`,uri:d.uri,rule:`first-supplier`});let f=new Set(r.map(e=>e.uri)),p=new Set;return s.relations=e.relations.filter(e=>{if(f.has(e.toUri))return!1;let t=`${e.relation}\u0000${e.toUri}`;return p.has(t)?!1:(p.add(t),!0)}).map(e=>({relation:e.relation,format:e.format,claimer:e.claimer,node:{titles:[],covers:[],...e.node,_id:e.toUri,uri:e.toUri,...RH(e.toUri,e.node)}})),s.handles=[...r.map(e=>({relation:`SAME_AS`,via:e.owned?`member`:`placeholder`,by:`plugin:aggregate`,node:zH(e)})),...VH(e.related).map(e=>({relation:e.relation,via:e.via,by:e.by,node:{_id:e.uri,uri:e.uri,origin:e.origin,id:e.id,url:e.url,handles:[],episodes:[]}}))],s},UH=(e,t)=>({_id:e._id,uri:e.uri,origin:String(e.origin??`ag`),id:String(e.id??``),url:e.url??null,handles:e.handles.map(e=>({relation:e.relation,node:{_id:String(e.node._id??e.node.uri??``),uri:String(e.node.uri??``),origin:String(e.node.origin??``),id:String(e.node.id??``),url:e.node.url??null}})),score:e.score??null,titles:AH(e.titles),shortDescriptions:AH(e.shortDescriptions),covers:AH(e.covers),banners:AH(e.banners),trailers:AH(e.trailers),averageScore:e.averageScore??null,nextAiringEpisode:e.nextAiringEpisode??null,popularity:e.popularity??null,episodeCount:e.episodeCount??null,type:e.type??null,status:e.status??null,season:e.season??null,seasonYear:e.seasonYear??null,genres:IH(e.genres),tags:IH(e.tags),categories:IH(e.categories),startDate:e.startDate??null,members:[...t].sort()}),WH=[`url`,`embedUrl`,`releaseDate`,`seasonNumber`,`absoluteEpisodeNumber`,`runtime`],GH=e=>{let t=OH(e.rows),n=[],r=LH(t.map(e=>e.uri)),i={_id:e.slot.id,uri:r.uri,id:r.id,origin:`ag`,mediaUri:e.clusterUri,episodeNumber:e.slot.number,score:t.length?Math.max(...t.map(e=>e.score??0)):null,handles:t.map(e=>({relation:`SAME_AS`,via:e.via,node:{...e.raw,_id:e.uri,uri:e.uri,origin:e.origin,id:e.id,handles:[]}})),provenance:n};for(let e of WH){let r=t.find(t=>t.raw[e]!==null&&t.raw[e]!==void 0);i[e]=r?r.raw[e]:null,r&&n.push({field:e,uri:r.uri,answerSeq:r.fieldSeq[e]??null,rule:`first-non-null`})}i.titles=FH(`title`,MH(t.flatMap(e=>AH(e.raw.titles))));for(let e of[`descriptions`,`shortDescriptions`,`thumbnails`])i[e]=MH(t.flatMap(t=>AH(t.raw[e])));for(let e of t)n.push({field:`titles`,uri:e.uri,answerSeq:e.fieldSeq.titles??null,rule:`concat`});return i},KH=new Map;let qH=!1;const JH=(e,t)=>(qH||(qH=!0,YL(`graph:changed`,()=>KH.clear()),YL(`row:changed`,()=>KH.clear()),YL(`view:changed`,()=>KH.clear())),KH.set(e,t),t);let YH=`legacy`;const XH=()=>YH,ZH=e=>{YH=e},QH=e=>{if(typeof e!=`string`||!e)return null;try{return JSON.parse(e)}catch{return console.error(Error(`graph read: a cluster column is not JSON: ${e.slice(0,80)}`)),null}},$H=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],eU=e=>({id:String(e.id),hidden:e.hidden===!0,hiddenBy:$H(e.hiddenBy),card:QH(e.card)}),tU=e=>e.map(e=>QH(e.card)).filter(e=>e!==null),nU=`coalesce(c.hidden, false) = false`,rU=e=>qS(e)?ZS(e)?.handleUris??[]:e?[e]:[],iU=async e=>{let{query:t}=await rH();if(!e){let e=await t(`MATCH (c:Cluster) WHERE ${nU} RETURN c.id AS id, c.card AS card`);return tU(e)}if(!e.length)return[];let n=(await t(`UNWIND $uris AS u
1393
+ MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster)
1394
+ RETURN DISTINCT c.id AS id, c.hidden AS hidden, c.hiddenBy AS hiddenBy, c.card AS card`,{uris:[...e]})).map(eU);return aU(n,t)},aU=async(e,t)=>{let n=new Map,r=new Set;for(let t of e)if(!t.hidden&&t.card&&n.set(t.id,t.card),t.hidden)for(let e of t.hiddenBy)r.add(e);for(let e of n.keys())r.delete(e);if(r.size){let e=await t(`UNWIND $ids AS hid MATCH (c:Cluster {id: hid}) WHERE ${nU} RETURN c.id AS id, c.card AS card`,{ids:[...r].sort()});for(let t of tU(e))n.set(t._id,t)}return[...n.values()]},oU=()=>{let e=new Map,t=(t,n)=>!n.length||e.has(t._id)||t.members.some(e=>n.includes(e));return{read:async t=>{e.clear();for(let n of await iU(t.length?t:void 0))e.set(n._id,n);return[...e.values()]},apply:async(n,r)=>{if(!n.length)return[...e.values()];let{query:i}=await rH(),a=(await i(`UNWIND $ids AS i MATCH (c:Cluster {id: i})
1395
+ RETURN c.id AS id, c.hidden AS hidden, c.hiddenBy AS hiddenBy, c.card AS card`,{ids:[...n]})).map(eU),o=new Set(a.map(e=>e.id));for(let t of n)o.has(t)||e.delete(t);let s=a.filter(n=>n.hidden&&(e.has(n.id)||n.card!==null&&t(n.card,r)));for(let n of a)n.hidden||!n.card?e.delete(n.id):t(n.card,r)&&e.set(n.id,n.card);for(let t of await aU(s,i))e.set(t._id,t);return[...e.values()]},cards:()=>[...e.values()]}},sU=`RETURN DISTINCT c.id AS id, c.scope AS scope, c.preferredRun AS preferredRun, c.key AS key,
1396
+ CASE WHEN c.scope = 'RUN' THEN 0 ELSE 1 END AS scopeRank
1397
+ ORDER BY scopeRank, key
1398
+ LIMIT 1`,cU=e=>e===void 0?void 0:{id:String(e.id),scope:String(e.scope??`RUN`),preferredRun:typeof e.preferredRun==`string`&&e.preferredRun?e.preferredRun:null},lU=async e=>{if(!e.length)return;let{query:t}=await rH(),[n]=await t(`UNWIND $uris AS u MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster) ${sU}`,{uris:[...e]});if(n)return cU(n);let[r]=await t(`UNWIND $uris AS u MATCH (c:Cluster) WHERE u IN c.published ${sU}`,{uris:[...e]});return cU(r)},uU=async e=>{let{query:t}=await rH(),[n]=await t(`MATCH (c:Cluster {id: $id}) RETURN c.id AS id, c.scope AS scope, c.preferredRun AS preferredRun`,{id:e});if(n)return cU(n);let[r]=await t(`MATCH (x:Alias {id: $id}) MATCH (c:Cluster {id: x.clusterId})
1399
+ RETURN c.id AS id, c.scope AS scope, c.preferredRun AS preferredRun`,{id:e});return cU(r)},dU=async(e,t)=>{if(!t.length)return!1;let{query:n}=await rH();return(await n(`UNWIND $uris AS u MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster {id: $id}) RETURN c.id AS id`,{id:e,uris:[...t]})).length>0},fU=async(e,t)=>{let n=t?rU(t):[],r=await lU(rU(e));if(!r&&e&&(r=await uU(e)),r||=await lU(n),!r)return;if(n.length&&!await dU(r.id,n)){let e=await lU(n);e&&(r=e)}let i=r.scope===`CONTAINER`&&r.preferredRun?r.preferredRun:r.id;return pU(i)},pU=async e=>{let t=`view#${e}`;if(KH.has(t))return KH.get(t);let{query:n}=await rH(),[r]=await n(`MATCH (c:Cluster {id: $id}) RETURN c.media AS media, c.kind AS kind`,{id:e});if(!r)return JH(t,void 0);let i=QH(r.media);return i?JH(t,typeof r.kind==`string`&&r.kind?{...i,kind:r.kind}:i):JH(t,void 0)},mU=e=>{if(typeof e==`object`&&e&&!Array.isArray(e))return e;if(typeof e!=`string`||!e)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}},hU=async e=>{let t=rU(e);if(!t.length)return;let{query:n}=await rH(),r=await n(`UNWIND $uris AS u
1400
+ MATCH (m:Media {uri: u})
1401
+ RETURN m.uri AS uri, m.origin AS origin, m.id AS id, m.owned AS owned, m.score AS score,
1402
+ m.raw AS raw, m.fieldSeq AS fieldSeq
1403
+ ORDER BY uri`,{uris:t});if(!r.length)return;let i=new Map;for(let e of[`CLAIMS`,`RELATED`]){let r=await n(`UNWIND $uris AS u
1404
+ MATCH (a:Media)-[c:${e}]->(b:Media {uri: u})
1405
+ RETURN u AS uri, c.node AS node, c.answerSeq AS answerSeq
1406
+ ORDER BY uri, answerSeq`,{uris:t});for(let e of r){let t=mU(e.node);Object.keys(t).length&&i.set(String(e.uri),t)}}let a=r.map(e=>({uri:String(e.uri),origin:String(e.origin??``),id:String(e.id??``),owned:e.owned===!0||i.has(String(e.uri)),score:typeof e.score==`number`?e.score:null,raw:Object.keys(mU(e.raw)).length?mU(e.raw):i.get(String(e.uri))??{},fieldSeq:Object.fromEntries(Object.entries(mU(e.fieldSeq)).map(([e,t])=>[e,typeof t==`number`?t:Number(t)]).filter(([,e])=>Number.isFinite(e)))})),o=a.map(e=>e.uri),[s]=await n(`UNWIND $uris AS u MATCH (p:MediaProfile)-[:PROFILE_OF]->(m:Media {uri: u})
1407
+ RETURN p.scope AS scope ORDER BY u`,{uris:o}),c=s?.scope===`CONTAINER`?`CONTAINER`:`RUN`;return HH({cluster:{id:o[0],aggUri:YS(o),scope:c,runLength:null,runLengthTier:null,runLengthWitnesses:0,runLengthFrom:[],anomalies:[]},members:a,related:[],relations:[],locationOrigin:typeof location>`u`?``:location.origin})},gU=(e,t)=>{let n=new Set([...rU(e),...t?rU(t):[]]),r,i=new Set(n);return{read:async()=>{let a=await fU(e,t);return a?(r=a._id,i=new Set([...n,...await bU([a._id])]),a):hU(e)},wakes:e=>r!==void 0&&e.clusters.includes(r)||e.clusters.some(e=>n.has(e))||e.uris.some(e=>i.has(e)),clusterId:()=>r}},_U=async e=>{if(!e)return[];let t=`episodes#${e}`;if(KH.has(t))return KH.get(t);let{query:n}=await rH(),[r]=await n(`MATCH (c:Cluster {id: $id}) RETURN c.episodes AS episodes`,{id:e});if(!r)return JH(t,[]);let i=QH(r.episodes);return Array.isArray(i)?JH(t,i.filter(e=>e.episodeNumber!==null&&e.episodeNumber!==void 0)):JH(t,[])},vU=async e=>{if(!e)return[];let{query:t}=await rH();return(await t(`MATCH (c:Cluster {id: $id})<-[:MEMBER_OF]-(:Media)-[cl:CLAIMS]->(t:Media {owned: false})
1408
+ RETURN DISTINCT t.uri AS uri, t.origin AS origin, cl.provenance AS provenance`,{id:e})).map(e=>({uri:String(e.uri),origin:String(e.origin??``),provenance:String(e.provenance??``)})).sort((e,t)=>e.uri.localeCompare(t.uri)||e.provenance.localeCompare(t.provenance))},yU=async(e,t)=>{let n=await vU(e);if(!n.length)return``;let r=[...rU(t),...n.map(e=>e.uri)],i=[...new Set(r.filter(e=>WS(e)&&HS(e)))];return i.length?YS(i):``},bU=async e=>{if(!e.length)return[];let{query:t}=await rH(),n=await t(`UNWIND $ids AS i MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster {id: i}) RETURN m.uri AS uri`,{ids:[...e]});return[...new Set(n.map(e=>String(e.uri)))].sort()},xU=`
1409
+ uri
1410
+ origin
1411
+ id
1412
+ url
1413
+ scope
1414
+ titles { language title score }
1415
+ episodes {
1416
+ uri
1417
+ origin
1418
+ id
1419
+ url
1420
+ embedUrl
1421
+ mediaUri
1422
+ score
1423
+ titles { language title score }
1424
+ descriptions { language description score }
1425
+ shortDescriptions { language shortDescription score }
1426
+ thumbnails { url width height language color score }
1427
+ releaseDate
1428
+ seasonNumber
1429
+ episodeNumber
1430
+ absoluteEpisodeNumber
1431
+ runtime
1432
+ }`,SU=`
1433
+ subscription SimilarMedia($input: SimilarMediaInput!) {
1434
+ similarMedia(input: $input) {${xU}
1435
+ }
1436
+ }
1437
+ `,CU=`
1438
+ subscription ContainingMedia($input: SimilarMediaInput!) {
1439
+ containingMedia(input: $input) {${xU}
1440
+ episodeCount
1441
+ }
1442
+ }
1443
+ `;let wU={};const TU=e=>{wU=e??{}},EU=e=>({uri:e.uri,origin:e.origin,id:e.id,url:e.url??null,embedUrl:e.embedUrl??null,mediaUri:e.mediaUri,score:e.score??null,titles:e.titles??[],descriptions:e.descriptions??[],shortDescriptions:e.shortDescriptions??[],thumbnails:e.thumbnails??[],releaseDate:e.releaseDate??null,seasonNumber:e.seasonNumber??null,episodeNumber:e.episodeNumber??null,absoluteEpisodeNumber:e.absoluteEpisodeNumber??null,runtime:e.runtime??null}),DU=e=>({id:e.id,url:e.url??null,name:e.name,icon:e.icon??null,color:e.color??null,isApiOnly:e.isApiOnly}),OU=async e=>{if(XH()===`graph`)return await fU(e);let t=await AR(e);if(!t.length&&qS(e)){let n=ZS(e);for(let e of n?.handleUris??[])if(t=await AR(e),t.length)break}if(t.length)return fz(t,location.origin)},kU=async function*(e,t){yield await OU(e.uri);let n=XH()===`graph`?QL([`view:changed`],{abortSignal:t?.abortSignal}):QL([`media:changed`,`episode:changed`],{abortSignal:t?.abortSignal});for await(let t of n)yield await OU(e.uri)},AU=new hx.default(async e=>{let t=e.flatMap(iz),n=[],r=new Set;for(let e of t)for(let t of e.handles??[]){if(!t?.node)continue;let i=`${e.uri}\0${t.node.uri}\0${t.relation}`;r.has(i)||(r.add(i),n.push({mediaUri:e.uri,handleUri:t.node.uri,relation:t.relation}))}return await ER(t.map(mz),n),e},{cache:!1,batch:!0,maxBatchSize:250,batchScheduleFn:e=>setTimeout(e,50)}),jU=new hx.default(async e=>{let t=[];for(let n of e)for(let e of n.handles??[])e?.node&&t.push({episodeUri:n.uri,handleUri:e.node.uri,relation:e.relation});return await RR(e.map(EU),t),e},{cache:!1,batch:!0,maxBatchSize:250,batchScheduleFn:e=>setTimeout(e,50)}),MU=new hx.default(async e=>(await HR(e.map(e=>DU({...e,url:e.url??null,icon:e.icon??null,color:e.color??null}))),e),{cache:!1,batch:!0,maxBatchSize:50,batchScheduleFn:e=>setTimeout(e,50)}),NU=3e4,PU=/^[A-Za-z0-9._~-]{1,128}$/,FU=new Map,IU=new Map,LU=(e,t,n=`similarMedia`)=>new Promise(r=>{let i=!1,a,o=e=>{i||(i=!0,clearTimeout(s),queueMicrotask(()=>{try{a?.unsubscribe()}catch{}}),r(e))},s=setTimeout(()=>o({kind:`timeout`}),NU);try{a=e.client.subscription(n===`containingMedia`?CU:SU,{input:t}).subscribe(e=>{if(e.error)return o({kind:`error`});if(!e.data)return;let t=e.data[n];o(t?{kind:`media`,media:t}:{kind:`null`})})}catch(t){console.error(Error(`Extractor ${e.name} failed to answer ${n}`,{cause:t})),o({kind:`error`})}}),RU=e=>WU.some(t=>t.extractor.origin===e&&!!t.extractor.resolvers.Subscription?.similarMedia),zU=e=>WU.some(t=>t.extractor.origin===e&&!!t.extractor.resolvers.Subscription?.containingMedia),BU=async(e,t,n,r)=>{let{showId:i}=n;if(!zU(t))return;if(!$D(n)){console.warn(`containingMedia: not asked ${t} ${i} for '${r}' (${nO(n)} carries no count to be longer than)`);return}console.warn(`containingMedia: asked ${t} ${i} by '${r}' with ${nO(n)}`);let a=await LU(e,n,`containingMedia`);if(a.kind===`media`)return GD(t,i,a.media)?(console.warn(`containingMedia: containing ${a.media.uri} to '${r}' for ${t} ${i} (${a.media.episodeCount??`-`} episodes)`),{outcome:`containing`,media:a.media}):(console.warn(`containingMedia: refused ${t} ${i} to '${r}' (not-a-run ${a.media.uri} scope ${a.media.scope??`RUN`})`),{outcome:`refused`,reason:`not-a-run`});if(a.kind===`timeout`)return console.warn(`containingMedia: declined ${t} ${i} to '${r}' (timeout ${NU}ms)`),{outcome:`declined`,reason:`timeout`};if(a.kind===`error`)return console.warn(`containingMedia: declined ${t} ${i} to '${r}' (error)`),{outcome:`declined`,reason:`error`};console.warn(`containingMedia: refused ${t} ${i} to '${r}' (null)`)},VU=e=>async(t,n)=>{if(!t||!n?.showId||!PD(n))return console.warn(`similarMedia: declined ${rO(t)} ${rO(n?.showId)} to '${e}' (no-evidence)`),{outcome:`declined`,reason:`no-evidence`};let r=LA(n);r&&(n={...n,context:NA(r,e)});let{showId:i}=n;if(!PU.test(i))return console.warn(`similarMedia: declined ${t} ${rO(i)} to '${e}' (bad-show-id)`),{outcome:`declined`,reason:`bad-show-id`};let a=RU(t)?WU.find(e=>e.extractor.origin===t):void 0;if(!a)return console.warn(`similarMedia: declined ${t} ${i} to '${e}' (not-implemented)`),{outcome:`declined`,reason:`not-implemented`};let o=oO(t,i,n),s=FU.get(o);if(s)return console.warn(`similarMedia: joined ${t} ${i} by '${e}' (in flight with the same evidence)`),s;let c=IU.get(e)??0;if(c>=8||FU.size>=32)return console.warn(`similarMedia: declined ${t} ${i} to '${e}' (ceiling ${c}/8 by caller, ${FU.size}/32 global)`),{outcome:`declined`,reason:`ceiling`};IU.set(e,c+1),console.warn(`similarMedia: asked ${t} ${i} by '${e}' with ${nO(n)}`);let l=LU(a,n).then(async r=>r.kind===`media`?GD(t,i,r.media)?(console.warn(`similarMedia: answered ${r.media.uri} to '${e}' for ${t} ${i}`),{outcome:`answered`,media:r.media}):(console.warn(`similarMedia: refused ${t} ${i} to '${e}' (not-a-run ${r.media.uri} scope ${r.media.scope??`RUN`})`),{outcome:`refused`,reason:`not-a-run`}):r.kind===`null`?await BU(a,t,n,e)||(console.warn(`similarMedia: refused ${t} ${i} to '${e}' (null)`),{outcome:`refused`,reason:`null`}):r.kind===`timeout`?(console.warn(`similarMedia: declined ${t} ${i} to '${e}' (timeout ${NU}ms)`),{outcome:`declined`,reason:`timeout`}):(console.warn(`similarMedia: declined ${t} ${i} to '${e}' (error)`),{outcome:`declined`,reason:`error`})).finally(()=>{FU.delete(o);let t=(IU.get(e)??1)-1;t>0?IU.set(e,t):IU.delete(e)});return FU.set(o,l),l},HU=e=>{let t=VU(e);return async(e,n)=>{let r=await t(e,n);return r.outcome===`answered`?r.media:void 0}},UU=e=>{let t=DU({...e,id:e.origin,url:e.originUrl,icon:e.icon??null,color:e.color??null}),n=up({schema:El({typeDefs:Lv,resolvers:AL({Media:{_id:e=>e.uri,handles:e=>e.handles??[],relations:e=>e.relations??[],categories:e=>e.categories??[],genres:e=>e.genres??[],tags:e=>e.tags??[],titles:e=>e.titles??[],descriptions:e=>e.descriptions??[],shortDescriptions:e=>e.shortDescriptions??[],covers:e=>e.covers??[],banners:e=>e.banners??[],trailers:e=>e.trailers??[],episodes:e=>e.episodes??[]},Episode:{_id:e=>e.uri,handles:e=>e.handles??[],descriptions:e=>e.descriptions??[],shortDescriptions:e=>e.shortDescriptions??[]},Query:{},Mutation:{},Subscription:{origin:{resolve:()=>t,subscribe:async function*(){return yield t}},originPage:{resolve:()=>({nodes:[t]}),subscribe:async function*(){yield[t]}},media:{subscribe:async function*(e){yield{media:null}}},mediaPage:{subscribe:async function*(e){yield{mediaPage:{nodes:[]}}}},similarMedia:{subscribe:async function*(e){yield{similarMedia:null}}},containingMedia:{subscribe:async function*(e){yield{containingMedia:null}}}}},e.resolvers)}),plugins:[yy({session:()=>null,ttl:900*1e3}),{onPluginInit:({addPlugin:e})=>{e(Bv(({info:e})=>async({result:t})=>{let n=Rt(e.returnType).name,r=wH(e,n,t);n===`Media`?Array.isArray(t)?await AU.loadMany(t):t&&await AU.load(t):n===`Episode`?Array.isArray(t)?await jU.loadMany(t):t&&await jU.load(t):n===`Origin`&&(Array.isArray(t)?await MU.loadMany(t):t&&await MU.load(t)),await r}))}}],maskedErrors:{maskError(t,n,r){return console.error(`Server Extractor ${e.name} GQLError occurred:`,t),new S(t.message)}}}),r=new mx({url:`http://d/graphql`,exchanges:[({forward:t})=>n=>wb(t(n),sb(t=>{t.error&&(t.error.networkError&&console.error(Error(`Client Extractor ${e.name} Network error on ${Kb(t.operation.query)}:`,{cause:t.error.networkError})),t.error.graphQLErrors?.length&&t.error.graphQLErrors.forEach(n=>{console.error(Error(`Client Extractor ${e.name} GraphQL error on ${Kb(t.operation.query)}:`,{cause:n}))}))})),dx],fetchSubscriptions:!0,fetch:async(t,r)=>n.handleRequest(new Request(t,r),{fetch:HL,key:e=>wU[e],findAggregatedMedia:e=>OU(e),listenForMediaChanges:kU,similarMedia:HU(e.origin)})});return{name:e.name,server:n,client:r,extractor:e,pluginUri:void 0}},WU=Object.values(OL).map(UU),GU=(e,t,n)=>{if(t===`media`||t===`similarMedia`||t===`containingMedia`)return n?.[t]&&n[t].origin!==e?(console.warn(`Plugin source '${e}' yielded media from origin '${n[t].origin}', dropped`),{[t]:null}):n;let r=n?.mediaPage?.nodes;if(!Array.isArray(r))return n;let i=r.filter(t=>t?.origin===e?!0:(console.warn(`Plugin source '${e}' yielded media from origin '${t?.origin}', dropped`),!1));return{...n,mediaPage:{...n.mediaPage,nodes:i}}},KU=(e,t)=>{let n=t.resolvers?.Subscription,r=t=>({subscribe:async function*(r,i){let a=n?.[t]?.subscribe;if(a)for await(let n of await a(void 0,i,{similarMedia:HU(e)}))yield GU(e,t,Sz(t,n))}});return{Query:{},Mutation:{},Subscription:{...n?.media?.subscribe?{media:r(`media`)}:{},...n?.mediaPage?.subscribe?{mediaPage:r(`mediaPage`)}:{},...n?.similarMedia?.subscribe?{similarMedia:r(`similarMedia`)}:{},...n?.containingMedia?.subscribe?{containingMedia:r(`containingMedia`)}:{}}}},qU=new Map,JU=e=>{let t=qU.get(e);return t?{pluginUri:t.pluginUri}:null},YU=async(e,t)=>{let n=qU.get(e);return n?await n.select(t)??null:null},XU=new Map,ZU=e=>{let t=XU.get(e);return t?{pluginUri:t}:null},QU=async(e,t)=>{let{sources:n,rejected:r}=gz(await jS(e),t);$U(t);let i=[],a=[...r];for(let{meta:e,source:r}of n)try{if(WU.some(t=>t.extractor.origin===e.origin))throw Error(`origin '${e.origin}' is already registered by another source`);let n=UU({...e,resolvers:KU(e.origin,r)});n.pluginUri=t,WU.push(n);let a=r.selectRelease;typeof a==`function`&&qU.set(e.origin,{pluginUri:t,select:a}),typeof r.play==`function`&&XU.set(e.origin,t);for(let e of eW)tW(e,n);i.push({origin:e.origin,name:e.name})}catch(n){let r=n instanceof Error?n.message:String(n);console.error(Error(`plugin '${t}': source '${e.origin}' failed to register`,{cause:n})),a.push({origin:e.origin,reason:r})}for(let e of a)console.warn(`plugin '${t}': skipped source '${e.origin}' (${e.reason})`);if(!i.length){let e=a.map(e=>`${e.origin}: ${e.reason}`).join(`; `);throw Error(`plugin '${t}': no source could be registered${e?` (${e})`:``}`)}return{sources:i,rejected:a}},$U=e=>{for(let[t,n]of qU)n.pluginUri===e&&qU.delete(t);for(let[t,n]of XU)n===e&&XU.delete(t);for(let t=WU.length-1;t>=0;--t){let n=WU[t];if(n.pluginUri===e){WU.splice(t,1);for(let e of eW)nW(e,n)}}},eW=new Set,tW=(e,t)=>{if(e.joined.has(t))return;let n;try{n=t.client.subscription(e.query,zA(e.variables??{},e.root)).subscribe(n=>{if(e.extractUris)try{for(let t of e.extractUris(n)??[])e.insertedUris.add(t)}catch(e){console.error(Error(`Extractor ${t.name} produced an unreadable fan-out result`,{cause:e}))}})}catch(e){console.error(Error(`Extractor ${t.name} failed to join the fan-out`,{cause:e}));return}e.joined.set(t,n),e.subscriptions.push(n)},nW=(e,t)=>{let n=e.joined.get(t);if(!n)return;e.joined.delete(t);let r=e.subscriptions.indexOf(n);r!==-1&&e.subscriptions.splice(r,1),Promise.resolve(n.unsubscribe()).catch(()=>{})},rW=(e,t,n)=>{let r=MA(t),i={query:e.params.query,variables:e.params.variables,insertedUris:new Set,extractUris:n,subscriptions:[],joined:new Map,root:r};for(let e of WU)tW(i,e);return eW.add(i),{subscriptions:i.subscriptions,insertedUris:i.insertedUris,askOrigins:(e,t)=>{for(let n of WU){let r=n.extractor;if(ML(r,e))try{i.subscriptions.push(n.client.subscription(i.query,zA(t??{},i.root)).subscribe(()=>{}))}catch(e){console.error(Error(`Extractor ${n.name} failed to re-join the fan-out`,{cause:e}))}}},root:r,close:()=>{eW.delete(i),IA(r.rootId)}}},iW=new Set([`imdb`,`trakt`,`tvdb`,`paramount`]),aW=new Set([`cr`,`nf`,`jw`]),oW=new Set([`nf`]),sW=new Set([`mal`,`anilist`,`anizip`,`offline`,`omdb`,`jw`]),cW={anizip:`entry`,nf:`position`},lW={mal:new Set([`anidb`,`anizip`]),anilist:new Set([`mal`,`cr`]),anizip:new Set([`mal`,`anilist`]),kitsu:new Set([`anilist`,`mal`,`cr`,`nf`,`hulu`,`disney`,`amazon`,`hbo`]),simkl:new Set([`imdb`,`mal`,`anilist`,`kitsu`]),trakt:new Set([`imdb`]),tvdb:new Set([`imdb`,`tmdb`]),tvmaze:new Set([`imdb`]),omdb:new Set([`imdb`]),watchmode:new Set([`imdb`,`tmdb`,`cr`,`nf`,`hulu`,`disney`,`amazon`,`hbo`]),jw:new Set([`cr`,`nf`,`disney`,`amazon`,`appletv`,`hulu`,`hbo`,`peacock`,`paramount`,`fubo`,`jw`]),cr:new Set,nf:new Set,appletv:new Set,tmdb:new Set},uW=new Set([`cr`,`nf`,`appletv`,`jw`]),dW=new Set([`SAME_AS`,`PART_OF`,`INCLUDES`]),fW=e=>typeof e==`object`&&!!e&&!Array.isArray(e),pW=e=>e.slice(0,e.indexOf(`:`)),mW=e=>e.slice(e.indexOf(`:`)+1),hW=e=>{let t=e.uri;if(!(typeof t!=`string`||!t||t.indexOf(`:`)<=0))return{uri:t,origin:typeof e.origin==`string`&&e.origin?e.origin:pW(t),id:typeof e.id==`string`&&e.id?e.id:mW(t)}},gW=e=>typeof e.scope==`string`&&e.scope?e.scope:null,_W=(e,t)=>e===`offline`&&t===`SAME_AS`,vW=(e,t,n,r)=>{if(_W(e,t))return`seed`;if(CW(n.provenance)===`address`)return`address`;if(t!==`SAME_AS`||r===e||!uW.has(e))return`source`;let i=lW[e];return i&&!i.has(r)?`address`:`source`},yW=(e,t)=>_W(e,t)?`seed`:`source`,bW=(e,t,n,r)=>{let i={...e};for(let e in t){let a=t[e],o=i[e];if(Array.isArray(a)){if(Array.isArray(o)&&o.length>a.length)continue;i[e]=a}else{if(a==null)continue;i[e]=a}r[e]=n}return i},xW=(e,t,n,r)=>{let i=e?.episodeNumber,a=r.episodeNumber,o=bW(e,t,n,r);return typeof i==`number`&&typeof o.episodeNumber==`number`&&i<o.episodeNumber&&(o.episodeNumber=i,a===void 0?delete r.episodeNumber:r.episodeNumber=a),o},SW=(e,t,n,r=bW)=>{let i=t;for(let{seq:t,value:a}of[...e].sort((e,t)=>e.seq-t.seq))i=r(i,a,t,n);return i??{}},CW=e=>typeof e==`string`?e:null,wW=e=>typeof e==`number`&&Number.isSafeInteger(e)?String(e):null,TW=e=>typeof e==`number`&&Number.isFinite(e)?String(e):null,EW=e=>e==null?null:JSON.stringify(e),DW=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`).join(`\0`):``,OW=e=>`CASE WHEN r.${e} = '' THEN cast(NULL AS STRING[]) ELSE string_split(r.${e}, $separator) END`,kW=`CASE WHEN r.fieldKeys = '' THEN cast(NULL AS MAP(STRING, INT64))
1444
+ ELSE map(string_split(r.fieldKeys, $separator), cast(string_split(r.fieldSeqs, $separator) AS INT64[])) END`,AW=e=>({scope:CW(e.scope),score:TW(e.score),episodeCount:wW(e.episodeCount),startDate:CW(e.startDate),endDate:CW(e.endDate),type:CW(e.type),status:CW(e.status),season:CW(e.season),seasonYear:wW(e.seasonYear),titles:EW(e.titles),categories:DW(e.categories)}),jW=e=>({mediaUri:CW(e.mediaUri),episodeNumber:wW(e.episodeNumber),seasonNumber:wW(e.seasonNumber),absoluteEpisodeNumber:wW(e.absoluteEpisodeNumber),releaseDate:CW(e.releaseDate),titles:EW(e.titles)}),MW=(e,t)=>Object.keys(e).every(n=>{let r=e[n],i=t[n];return Array.isArray(r)&&Array.isArray(i)?r.length===i.length&&r.every((e,t)=>e===i[t]):r===i}),NW=(e,t,n,r)=>{let i=e.media.get(t);if(i)return i;let a={uri:t,origin:n,id:r,owned:!1,stamp:null,contributions:[]};return e.media.set(t,a),a},PW=(e,t,n,r)=>{e.quarantined.push({key:t,uri:n,reason:r})},FW=(e,t,n,r)=>{let i=[n.fromUri,n.toUri,n.kind,n.claimer,n.provenance].join(`\0`),a=t.get(i);if(!a){t.set(i,{...n,contributions:[{seq:n.answerSeq,value:r}]});return}a.contributions.push({seq:n.answerSeq,value:r}),a.answerSeq=Math.max(a.answerSeq,n.answerSeq)},IW=(e,t,n,r)=>{if(!fW(n)){PW(e,t.key,``,`an episode entry is not a row`);return}let i=hW(n);if(!i){PW(e,t.key,typeof n.uri==`string`?n.uri:``,`an episode carries no uri an origin can be read from`);return}let a=typeof n.mediaUri==`string`&&n.mediaUri.indexOf(`:`)>0?n.mediaUri:null,o=e.episodes.get(i.uri)??{...i,owned:!1,stamp:null,contributions:[],mediaUri:null};if(e.episodes.set(i.uri,o),o.mediaUri??=a,r&&(o.owned=!0,o.contributions.push({seq:t.seq,value:n})),!a)PW(e,t.key,i.uri,`an episode names no media, so no HAS_EPISODE could be written`);else{NW(e,a,pW(a),mW(a));let n=`${a}\0${i.uri}\0${t.origin}`;e.hasEpisode.has(n)||e.hasEpisode.set(n,{fromUri:a,toUri:i.uri,claimer:t.origin,answerSeq:t.seq})}for(let r of Array.isArray(n.handles)?n.handles:[]){if(!fW(r)||!fW(r.node)){e.handlesWithNoNode+=1;continue}let n=hW(r.node);if(!n){PW(e,t.key,i.uri,`an episode handle names no uri an origin can be read from`);continue}e.episodes.has(n.uri)||e.episodes.set(n.uri,{...n,owned:!1,stamp:null,contributions:[],mediaUri:null});let a=typeof r.relation==`string`&&dW.has(r.relation)?r.relation:`SAME_AS`;FW(e,e.episodeClaims,{fromUri:i.uri,toUri:n.uri,kind:a,provenance:yW(t.origin,a),claimer:t.origin,targetScope:gW(r.node),answerSeq:t.seq},r.node)}},LW=(e,t,n,r)=>{if(!fW(n)){PW(e,t.key,``,`a handle names no media row`);return}let i=hW(n);if(!i){PW(e,t.key,typeof n.uri==`string`?n.uri:``,`a row carries no uri an origin can be read from`);return}let a=NW(e,i.uri,i.origin,i.id);a.stamp??=gW(n);let o=i.origin===t.origin;o&&(a.owned=!0,a.contributions.push({seq:t.seq,value:r.viaPartOf?{...n,handles:[]}:n}));let s=Array.isArray(n.episodes)?n.episodes:[];if(o){for(let n of s)IW(e,t,n,!0);for(let r of Array.isArray(n.relations)?n.relations:[]){if(!fW(r)||!fW(r.node))continue;let n=hW(r.node);if(!n)continue;NW(e,n.uri,n.origin,n.id);let a=CW(r.relation)??`UNKNOWN`,o=`${i.uri}\0${n.uri}\0${a}\0${t.origin}`;e.related.has(o)||e.related.set(o,{fromUri:i.uri,toUri:n.uri,relation:a,format:CW(r.format),claimer:t.origin,node:r.node,answerSeq:t.seq})}}else e.declinedEpisodes+=s.length;if(r.viaPartOf||r.depth<=0)return i.uri;for(let a of Array.isArray(n.handles)?n.handles:[]){if(!fW(a)||!fW(a.node)){e.handlesWithNoNode+=1;continue}let n=typeof a.relation==`string`&&dW.has(a.relation)?a.relation:`SAME_AS`,o=LW(e,t,a.node,{depth:r.depth-1,viaPartOf:n===`PART_OF`});o&&FW(e,e.claims,{fromUri:i.uri,toUri:o,kind:n,provenance:vW(t.origin,n,a,pW(o)),claimer:t.origin,targetScope:gW(a.node),answerSeq:t.seq},a.node)}return i.uri},RW=e=>{let t={answers:[],media:new Map,episodes:new Map,origins:new Map,claims:new Map,episodeClaims:new Map,hasEpisode:new Map,related:new Map,about:[],quarantined:[],declinedEpisodes:0,handlesWithNoNode:0};for(let n of e){let e;try{e=typeof n.raw==`string`?JSON.parse(n.raw):JSON.parse(JSON.stringify(n.raw))}catch{PW(t,n.key??``,n.uri??``,`raw is not JSON`);continue}if(!fW(e)){PW(t,n.key??``,n.uri??``,`raw is not a row`);continue}if(!n.key||typeof n.seq!=`number`){PW(t,n.key??``,n.uri??``,`the answer carries no key or no seq`);continue}if(n.kind===`origin`){let r=typeof e.id==`string`&&e.id?e.id:n.uri;if(!r){PW(t,n.key,``,`an origin carries no id`);continue}let i=t.origins.get(r)??{uri:r,origin:r,id:r,owned:!0,stamp:null,contributions:[]};i.contributions.push({seq:n.seq,value:e}),t.origins.set(r,i),t.answers.push(n),t.about.push({key:n.key,uri:r,kind:`origin`});continue}if(n.kind===`episode`){IW(t,n,e,!0);let r=hW(e);if(!r)continue;t.answers.push(n),t.about.push({key:n.key,uri:r.uri,kind:`episode`});continue}let r=LW(t,n,e,{depth:4,viaPartOf:!1});r&&(t.answers.push(n),t.about.push({key:n.key,uri:r,kind:`media`}))}return t},zW=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},BW=2e3,VW=async(e,t,n,r=`rows`)=>{for(let i of zW(n,BW))await e(t,{separator:`\0`,[r]:i});return n.length};let HW=0;const UW=async e=>{let t=Date.now(),n=RW(e),r={},i={media:[],claims:[],episodes:[],raw:[]},a=()=>({answers:e.length,quarantined:n.quarantined,changed:i,written:r,declinedEpisodes:n.declinedEpisodes,handlesWithNoNode:n.handlesWithNoNode,ms:Date.now()-t});if(!n.answers.length&&!n.media.size&&!n.episodes.size&&!n.origins.size)return a();let{query:o}=await rH(),s=String(++HW),c=n.answers.map(e=>e.key),l=new Set;for(let e of zW(c,BW)){let t=await o(`UNWIND $keys AS k MATCH (a:Answer {key: k}) RETURN a.key AS key`,{keys:e});for(let e of t)l.add(e.key)}let u=[...n.media.keys()],d=new Map;for(let e of zW(u,BW)){let t=await o(`UNWIND $uris AS u MATCH (m:Media {uri: u}) RETURN m.uri AS uri, m.raw AS raw, m.hash AS hash, m.owned AS owned, m.fieldSeq AS fieldSeq`,{uris:e});for(let e of t)d.set(e.uri,{raw:e.raw??null,hash:e.hash??null,owned:e.owned===!0,fieldSeq:e.fieldSeq??null})}let f=[...n.episodes.keys()],p=new Map;for(let e of zW(f,BW)){let t=await o(`UNWIND $uris AS u MATCH (e:Episode {uri: u}) RETURN e.uri AS uri, e.raw AS raw, e.hash AS hash, e.fieldSeq AS fieldSeq`,{uris:e});for(let e of t)p.set(e.uri,{raw:e.raw??null,hash:e.hash??null,owned:!0,fieldSeq:e.fieldSeq??null})}let m=[...n.origins.keys()],h=new Map;for(let e of zW(m,BW)){let t=await o(`UNWIND $ids AS i MATCH (o:Origin {id: i}) RETURN o.id AS id, o.raw AS raw, o.hash AS hash`,{ids:e});for(let e of t)h.set(e.id,{raw:e.raw??null,hash:e.hash??null,owned:!0,fieldSeq:null})}let g=new Map;await Promise.all([...n.claims.keys()].map(async e=>{g.set(e,await WV(e))}));let _=new Map;await Promise.all([...n.episodeClaims.keys()].map(async e=>{_.set(e,await WV(e))}));let v=new Map;await Promise.all([...n.hasEpisode.keys()].map(async e=>{v.set(e,await WV(e))}));let y=new Map;for(let e of zW([...g.values()],BW)){let t=await o(`UNWIND $keys AS k MATCH (a:Media)-[c:CLAIMS {key: k}]->(b:Media) RETURN c.key AS key, c.node AS node, c.hash AS hash, c.answerSeq AS answerSeq`,{keys:e});for(let e of t)y.set(e.key,e)}let b=new Set;for(let e of zW([..._.values()],BW)){let t=await o(`UNWIND $keys AS k MATCH (a:Episode)-[c:EPISODE_CLAIMS {key: k}]->(b:Episode) RETURN c.key AS key`,{keys:e});for(let e of t)b.add(e.key)}let x=new Set;for(let e of zW([...v.values()],BW)){let t=await o(`UNWIND $keys AS k MATCH (m:Media)-[h:HAS_EPISODE {key: k}]->(e:Episode) RETURN h.key AS key`,{keys:e});for(let e of t)x.add(e.key)}let S=n.answers.filter(e=>!l.has(e.key));S.length&&(r.Answer=await VW(o,`UNWIND $rows AS r
1445
+ CREATE (:Answer {key: r.key, seq: cast(r.seq AS INT64), uri: r.uri, origin: r.origin, kind: r.kind,
1446
+ operation: r.operation, selection: ${OW(`selection`)}, raw: r.raw})`,S.map(e=>({key:e.key,seq:String(e.seq),uri:e.uri,origin:e.origin,kind:e.kind,operation:e.operation,selection:(e.selection??[]).join(`\0`),raw:e.raw}))));let C=[];for(let[e,t]of n.origins){let n=h.get(e),r=n?.raw?JSON.parse(n.raw):void 0,i=SW(t.contributions,r,{}),a=await GV(i);n?.hash!==a&&C.push({id:e,raw:JSON.stringify(i),hash:a,seq:s})}C.length&&(r.Origin=await VW(o,`UNWIND $rows AS r
1447
+ MERGE (o:Origin {id: r.id})
1448
+ ON CREATE SET o.raw = r.raw, o.hash = r.hash, o.seq = cast(r.seq AS INT64)
1449
+ ON MATCH SET o.raw = r.raw, o.hash = r.hash, o.seq = cast(r.seq AS INT64)`,C));let w=[],ee=[];for(let[e,t]of n.media){let n=d.get(e);if(!t.owned||!t.contributions.length){if(n)continue;ee.push({uri:e,origin:t.origin,id:t.id,scope:t.stamp,seq:s}),i.media.push(e);continue}let r=n?.raw?JSON.parse(n.raw):void 0,a={...n?.fieldSeq},o=SW(t.contributions,r,a),c=await GV(o);if(n?.hash===c&&n.owned)continue;let l=AW(o);w.push({uri:e,origin:t.origin,id:t.id,owned:`true`,raw:JSON.stringify(o),...l,fieldKeys:Object.keys(a).join(`\0`),fieldSeqs:Object.values(a).map(String).join(`\0`),hash:c,seq:s}),!n||!n.owned||!r||!MW(l,AW(r))?i.media.push(e):i.raw.push(e)}if(ee.length&&(r.MediaPlaceholder=await VW(o,`UNWIND $rows AS r
1450
+ MERGE (m:Media {uri: r.uri})
1451
+ ON CREATE SET m.origin = r.origin, m.id = r.id, m.owned = false, m.scope = r.scope, m.seq = cast(r.seq AS INT64)`,ee)),w.length){let e=`m.origin = r.origin, m.id = r.id, m.owned = cast(r.owned AS BOOLEAN), m.scope = r.scope,
1452
+ m.raw = r.raw, m.score = cast(r.score AS DOUBLE), m.episodeCount = cast(r.episodeCount AS INT64),
1453
+ m.startDate = r.startDate, m.endDate = r.endDate, m.type = r.type, m.status = r.status,
1454
+ m.season = r.season, m.seasonYear = cast(r.seasonYear AS INT64), m.titles = r.titles,
1455
+ m.categories = ${OW(`categories`)},
1456
+ m.fieldSeq = ${kW},
1457
+ m.hash = r.hash, m.seq = cast(r.seq AS INT64)`;r.Media=await VW(o,`UNWIND $rows AS r MERGE (m:Media {uri: r.uri}) ON CREATE SET ${e} ON MATCH SET ${e}`,w)}let te=[],ne=[];for(let[e,t]of n.episodes){let n=p.get(e);if(!t.contributions.length){if(n)continue;ne.push({uri:e,origin:t.origin,id:t.id,mediaUri:t.mediaUri,seq:s});continue}let r=n?.raw?JSON.parse(n.raw):void 0,a={...n?.fieldSeq},o=SW(t.contributions,r,a,xW),c=await GV(o);if(n?.hash===c)continue;let l=jW(o);te.push({uri:e,origin:t.origin,id:t.id,raw:JSON.stringify(o),...l,fieldKeys:Object.keys(a).join(`\0`),fieldSeqs:Object.values(a).map(String).join(`\0`),hash:c,seq:s}),(!n||!r||!MW(l,jW(r)))&&l.mediaUri&&i.media.push(l.mediaUri)}if(ne.length&&(r.EpisodePlaceholder=await VW(o,`UNWIND $rows AS r
1458
+ MERGE (e:Episode {uri: r.uri})
1459
+ ON CREATE SET e.origin = r.origin, e.id = r.id, e.mediaUri = r.mediaUri, e.seq = cast(r.seq AS INT64)`,ne)),te.length){let e=`e.origin = r.origin, e.id = r.id, e.mediaUri = r.mediaUri, e.raw = r.raw,
1460
+ e.episodeNumber = cast(r.episodeNumber AS INT64), e.seasonNumber = cast(r.seasonNumber AS INT64),
1461
+ e.absoluteEpisodeNumber = cast(r.absoluteEpisodeNumber AS INT64), e.releaseDate = r.releaseDate,
1462
+ e.titles = r.titles, e.fieldSeq = ${kW},
1463
+ e.hash = r.hash, e.seq = cast(r.seq AS INT64)`;r.Episode=await VW(o,`UNWIND $rows AS r MERGE (e:Episode {uri: r.uri}) ON CREATE SET ${e} ON MATCH SET ${e}`,te)}let re=[],ie=[];for(let[e,t]of n.claims){let n=g.get(e),r=y.get(n),a=r?.node?JSON.parse(r.node):void 0,o=SW(t.contributions,a,{}),c=await GV(o),l={key:n,fromUri:t.fromUri,toUri:t.toUri,kind:t.kind,provenance:t.provenance,claimer:t.claimer,targetScope:t.targetScope,node:JSON.stringify(o),hash:c,answerSeq:String(t.answerSeq),seq:s};if(!r){re.push(l),i.claims.push(n);continue}r.hash!==c&&(ie.push({...l,answerSeq:String(Math.max(t.answerSeq,r.answerSeq??0))}),i.raw.push(t.toUri))}re.length&&(r.CLAIMS=await VW(o,`UNWIND $rows AS h
1464
+ MATCH (a:Media {uri: h.fromUri}), (b:Media {uri: h.toUri})
1465
+ WHERE NOT EXISTS { MATCH (a)-[:CLAIMS {key: h.key}]->(b) }
1466
+ CREATE (a)-[:CLAIMS {key: h.key, kind: h.kind, provenance: h.provenance, claimer: h.claimer,
1467
+ targetScope: h.targetScope, node: h.node, hash: h.hash,
1468
+ answerSeq: cast(h.answerSeq AS INT64), seq: cast(h.seq AS INT64)}]->(b)`,re)),ie.length&&(r.CLAIMS_REASSERTED=await VW(o,`UNWIND $rows AS h
1469
+ MATCH (a:Media {uri: h.fromUri})-[c:CLAIMS {key: h.key}]->(b:Media {uri: h.toUri})
1470
+ SET c.node = h.node, c.hash = h.hash, c.answerSeq = cast(h.answerSeq AS INT64), c.seq = cast(h.seq AS INT64)`,ie));let ae=[];for(let[e,t]of n.episodeClaims){let n=_.get(e);if(b.has(n))continue;let r=SW(t.contributions,void 0,{});ae.push({key:n,fromUri:t.fromUri,toUri:t.toUri,kind:t.kind,provenance:t.provenance,claimer:t.claimer,node:JSON.stringify(r),answerSeq:String(t.answerSeq),seq:s})}ae.length&&(r.EPISODE_CLAIMS=await VW(o,`UNWIND $rows AS h
1471
+ MATCH (a:Episode {uri: h.fromUri}), (b:Episode {uri: h.toUri})
1472
+ WHERE NOT EXISTS { MATCH (a)-[:EPISODE_CLAIMS {key: h.key}]->(b) }
1473
+ CREATE (a)-[:EPISODE_CLAIMS {key: h.key, kind: h.kind, provenance: h.provenance, claimer: h.claimer,
1474
+ node: h.node, answerSeq: cast(h.answerSeq AS INT64), seq: cast(h.seq AS INT64)}]->(b)`,ae));let T=[];for(let[e,t]of n.hasEpisode){let n=v.get(e);x.has(n)||(T.push({key:n,fromUri:t.fromUri,toUri:t.toUri,claimer:t.claimer,answerSeq:String(t.answerSeq),seq:s}),i.episodes.push(t.toUri),i.media.push(t.fromUri))}T.length&&(r.HAS_EPISODE=await VW(o,`UNWIND $rows AS h
1475
+ MATCH (m:Media {uri: h.fromUri}), (e:Episode {uri: h.toUri})
1476
+ WHERE NOT EXISTS { MATCH (m)-[:HAS_EPISODE {key: h.key}]->(e) }
1477
+ CREATE (m)-[:HAS_EPISODE {key: h.key, claimer: h.claimer, answerSeq: cast(h.answerSeq AS INT64), seq: cast(h.seq AS INT64)}]->(e)`,T));let E=[];if(n.related.size){let e=new Set,t=[...n.related.values()].map(e=>({fromUri:e.fromUri,toUri:e.toUri,relation:e.relation,claimer:e.claimer}));for(let n of zW(t,BW)){let t=await o(`UNWIND $rows AS r
1478
+ MATCH (a:Media {uri: r.fromUri})-[e:RELATED {relation: r.relation, claimer: r.claimer}]->(b:Media {uri: r.toUri})
1479
+ RETURN a.uri AS fromUri, b.uri AS toUri, e.relation AS relation, e.claimer AS claimer`,{rows:n});for(let n of t)e.add(`${n.fromUri}\0${n.toUri}\0${n.relation}\0${n.claimer}`)}for(let[t,r]of n.related)e.has(t)||E.push(r)}E.length&&(r.RELATED=await VW(o,`UNWIND $rows AS r
1480
+ MATCH (a:Media {uri: r.fromUri}), (b:Media {uri: r.toUri})
1481
+ WHERE NOT EXISTS { MATCH (a)-[:RELATED {relation: r.relation, claimer: r.claimer}]->(b) }
1482
+ CREATE (a)-[:RELATED {relation: r.relation, format: r.format, claimer: r.claimer, node: r.node,
1483
+ answerSeq: cast(r.answerSeq AS INT64)}]->(b)`,E.map(e=>({fromUri:e.fromUri,toUri:e.toUri,relation:e.relation,format:e.format,claimer:e.claimer,node:JSON.stringify(e.node),answerSeq:String(e.answerSeq)}))));let oe=[{kind:`media`,label:`Media`,field:`uri`},{kind:`episode`,label:`Episode`,field:`uri`},{kind:`origin`,label:`Origin`,field:`id`}],se=new Set;for(let e of zW(c,BW)){let t=await o(`UNWIND $keys AS k MATCH (a:Answer {key: k})-[:ABOUT]->() RETURN a.key AS key`,{keys:e});for(let e of t)se.add(e.key)}for(let e of oe){let t=n.about.filter(t=>t.kind===e.kind&&!se.has(t.key));if(t.length&&(r.ABOUT=(r.ABOUT??0)+await VW(o,`UNWIND $rows AS r
1484
+ MATCH (a:Answer {key: r.key}), (n:${e.label} {${e.field}: r.uri})
1485
+ WHERE NOT EXISTS { MATCH (a)-[:ABOUT]->(n) }
1486
+ CREATE (a)-[:ABOUT]->(n)`,t.map(e=>({key:e.key,uri:e.uri}))),e.kind===`media`))for(let e of t)i.media.push(e.uri)}let ce=new Set(i.media);return i.media=[...ce],i.episodes=[...new Set(i.episodes)],i.raw=[...new Set(i.raw)].filter(e=>!ce.has(e)),(i.media.length||i.claims.length||i.episodes.length)&&JL(`graph:changed`,{seq:HW,uris:i.media,episodes:i.episodes,claims:i.claims}),i.raw.length&&JL(`row:changed`,{uris:i.raw}),a()};let WW=Promise.resolve();const GW=e=>{let t=WW.then(()=>UW(e));return WW=t.catch(()=>void 0),t},KW=async e=>{let{query:t}=await rH(),n=await WV([e.fromUri,e.toUri,e.kind,e.claimer,`ask`].join(`\0`)),[r]=await t(`MATCH (a:Media)-[c:CLAIMS {key: $key}]->(b:Media) RETURN c.key AS key`,{key:n});if(r)return{key:n,written:!1,placeholders:[]};let i=String(++HW),a=[{uri:e.fromUri,scope:null},{uri:e.toUri,scope:e.targetScope}],o=new Set((await t(`UNWIND $uris AS u MATCH (m:Media {uri: u}) RETURN m.uri AS uri`,{uris:a.map(e=>e.uri)})).map(e=>e.uri)),s=a.filter(e=>!o.has(e.uri));return s.length&&await t(`UNWIND $rows AS r
1487
+ MERGE (m:Media {uri: r.uri})
1488
+ ON CREATE SET m.origin = r.origin, m.id = r.id, m.owned = false, m.scope = r.scope, m.seq = cast(r.seq AS INT64)`,{rows:s.map(e=>({uri:e.uri,origin:pW(e.uri),id:mW(e.uri),scope:e.scope,seq:i}))}),await t(`UNWIND $rows AS h
1489
+ MATCH (a:Media {uri: h.fromUri}), (b:Media {uri: h.toUri})
1490
+ WHERE NOT EXISTS { MATCH (a)-[:CLAIMS {key: h.key}]->(b) }
1491
+ CREATE (a)-[:CLAIMS {key: h.key, kind: h.kind, provenance: h.provenance, claimer: h.claimer,
1492
+ targetScope: h.targetScope, node: h.node, hash: h.hash,
1493
+ answerSeq: cast(h.answerSeq AS INT64), seq: cast(h.seq AS INT64)}]->(b)`,{rows:[{key:n,fromUri:e.fromUri,toUri:e.toUri,kind:e.kind,provenance:`ask`,claimer:e.claimer,targetScope:e.targetScope,node:JSON.stringify(e.node),hash:await GV(e.node),answerSeq:`0`,seq:i}]}),JL(`graph:changed`,{seq:HW,uris:s.map(e=>e.uri),episodes:[],claims:[n]}),{key:n,written:!0,placeholders:s.map(e=>e.uri)}},qW=async e=>{let{query:t}=await rH(),n=await t(`MATCH (m:Media {uri: $runUri})-[:MEMBER_OF]->(c:Cluster)<-[:MEMBER_OF]-(o:Media)
1494
+ WHERE o.scope IS NULL OR o.scope <> 'CONTAINER'
1495
+ RETURN o.uri AS uri, o.origin AS origin`,{runUri:e}),r=new Set;return n.map(e=>({uri:String(e.uri),origin:String(e.origin)})).filter(e=>!r.has(e.uri)&&r.add(e.uri)).sort((e,t)=>e.uri<t.uri?-1:+(e.uri>t.uri))},JW=e=>{let t=WW.then(()=>KW(e));return WW=t.catch(()=>void 0),t};let YW=[],XW,ZW,QW,$W=Promise.resolve(),eG=0;const tG=new Set,nG=async e=>{if(!e.length)return;let{query:t}=await rH();await t(`UNWIND $rows AS r
1496
+ CREATE (:Ask {key: r.key, clusterId: r.clusterId, runUri: r.runUri, origin: r.origin, showId: r.showId,
1497
+ questionHash: r.questionHash, outcome: r.outcome, reason: r.reason,
1498
+ answerUri: CASE WHEN r.answerUri = '' THEN cast(NULL AS STRING) ELSE r.answerUri END,
1499
+ seq: cast(r.seq AS INT64)})`,{rows:e.map(e=>({...e,answerUri:e.answerUri??``,seq:String(e.seq)}))})},rG=()=>{XW!==void 0&&clearTimeout(XW);let e=ZW;XW=void 0,ZW=void 0,QW=void 0;let t=YW;return YW=[],$W=$W.then(()=>nG(t)).catch(e=>{console.error(Error(`graph: the ask log dropped ${t.length} row(s)`,{cause:e}))}).finally(()=>e?.()),$W},iG=()=>(QW??=new Promise(e=>{ZW=e}),XW??=setTimeout(()=>{rG()},50),QW),aG=async e=>{let t=++eG,n=await WV(e.question),r=await WV([e.clusterId,e.origin,e.showId,n,t].join(`\0`));YW.push({key:r,seq:t,clusterId:e.clusterId,runUri:e.runUri,origin:e.origin,showId:e.showId,questionHash:n,outcome:e.outcome,reason:e.reason,answerUri:e.outcome===`answered`||e.outcome===`containing`?e.reason:null})},oG=e=>{if(!zV())return;let t=aG(e).catch(e=>{console.error(Error(`graph: the ask log could not key a row`,{cause:e}))});return tG.add(t),t.finally(()=>{tG.delete(t)}),t.then(()=>iG())},sG=async()=>{for(;tG.size||YW.length||XW!==void 0;)await Promise.all([...tG]),(YW.length||XW!==void 0)&&await rG();await $W},cG=async()=>{if(!zV())throw Error(`graph: the ask log is off, load the page with ?graph=1`);await sG();let{query:e}=await rH();return await e(`MATCH (k:Ask)
1500
+ RETURN k.key AS key, k.seq AS seq, k.clusterId AS clusterId, k.runUri AS runUri,
1501
+ k.origin AS origin, k.showId AS showId, k.questionHash AS questionHash,
1502
+ k.outcome AS outcome, k.reason AS reason, k.answerUri AS answerUri
1503
+ ORDER BY k.seq`)},lG=new Map,uG=e=>{for(;e.mergedInto;)e=e.mergedInto;return e},dG=(e,t)=>{let n=lG.get(e);n||(n=[],lG.set(e,n));let r=n.filter(e=>t.some(t=>e.members.has(t.uri)));if(!r.length){let e={members:new Set(t.map(e=>e.uri)),fingerprints:new Set,refusedTitles:new Set,asks:0,settled:!1,skipLogged:!1};return n.push(e),e}let[i,...a]=r;for(let e of a){for(let t of e.members)i.members.add(t);for(let t of e.fingerprints)i.fingerprints.add(t);for(let t of e.refusedTitles)i.refusedTitles.add(t);i.asks+=e.asks,i.settled=i.settled||e.settled,i.driver=i.driver??e.driver,i.latest=i.latest??e.latest,e.mergedInto=i,n.splice(n.indexOf(e),1)}for(let e of t)i.members.add(e.uri);return a.length&&console.warn(`similarMedia: consumer merged ${r.length} records under ${e} (${i.members.size} members)`),i},fG=e=>[...new Set(e)],pG=(e,t,n)=>({fingerprint:oO(e.origin,e.showId,t),clusterId:n,titles:[...t.titles??[]].sort().join(``),evidence:t,ask:e}),mG=(e,t,n)=>{if(!zV())return;let r=e=>console.error(Error(`similarMedia consumer could not record an ask`,{cause:e}));try{oG({clusterId:e.clusterId,runUri:e.ask.runUri,origin:e.ask.origin,showId:e.ask.showId,question:e.fingerprint,outcome:t,reason:n})?.catch(r)}catch(e){r(e)}},hG=async(e,t,n)=>{if(zV())try{let{uri:r,origin:i,id:a,scope:o,titles:s}=t;await JW({fromUri:e.runUri,toUri:t.uri,kind:n,claimer:e.origin,targetScope:o??null,node:{uri:r,origin:i,id:a,scope:o??null,titles:s?[...s]:null}})}catch(e){console.error(Error(`similarMedia consumer could not claim an answer`,{cause:e}))}},gG=async e=>{if(zV()&&XH()===`graph`)try{return await qW(e)}catch(e){console.error(Error(`similarMedia consumer could not read the graph cluster`,{cause:e}))}return(await AR(e)).filter(e=>e.scope!==`CONTAINER`)},_G=e=>{let t=e.filter(e=>e.scope!==`CONTAINER`),n=t.filter(e=>(e.titles??[]).some(e=>e.title?.trim()));return(n.length?n:t).map(e=>e.uri).sort()[0]},vG=(e,t)=>e.fingerprints.has(t.fingerprint)||e.refusedTitles.has(t.titles),yG=(e,t,n,r)=>{let i=_G(e);if(!i)return[];let a=r??new Set(e.map(e=>e.origin)),o=[],s=new Set;for(let e of t)s.has(e.uri)||(s.add(e.uri),e.scope===`CONTAINER`&&n(e.origin)&&(a.has(e.origin)||o.push({runUri:i,origin:e.origin,showId:e.id,containerUri:e.uri})));return o},bG=(e,t)=>e.score==null?t.score==null?0:1:t.score==null?-1:t.score-e.score,xG=(e,t)=>{let n=[...e].sort(bG);return{titles:fG(n.flatMap(e=>(e.titles??[]).map(e=>e.title))).filter(e=>!Jw(e)),startDate:WD(n.map(e=>e.startDate)),episodeCount:tR(e)??void 0,episodeTitles:fG(t).slice(0,200)}},SG=async(e,t,n)=>{if(e.driver){let{ask:t}=e.latest;console.warn(`similarMedia: consumer deferred ${t.origin} ${t.showId} for ${t.runUri} (an ask is in flight; asked when it settles if still new)`);return}let r=Symbol(`similarMedia consumer driver`);e.driver=r;let i=e,a;try{for(;;){if(i=uG(i),i.driver??=r,i.driver!==r||i.settled||!i.latest||vG(i,i.latest))return;let e=i.latest,{evidence:o,ask:s}=e;if(i.asks>=4){i.settled=!0,console.warn(`similarMedia: consumer settled ${s.origin} ${s.showId} for ${s.runUri} (cap 4 reached)`);return}i.asks+=1,a=e,console.warn(`similarMedia: consumer asked ${s.origin} ${s.showId} for ${s.runUri} (ask ${i.asks} of 4) with ${nO(o)}`);let c=await n.ask(s.origin,{showId:s.showId,context:t,startDate:o.startDate??void 0,titles:o.titles?[...o.titles]:void 0,episodeCount:o.episodeCount??void 0,episodeTitles:o.episodeTitles?[...o.episodeTitles]:void 0});if(i=uG(i),i.settled){console.warn(`similarMedia: consumer dropped ${s.origin} ${s.showId} for ${s.runUri} (the pair settled while the ask was in flight)`),mG(e,`refused`,`dropped`);return}if(c.outcome===`declined`){console.warn(`similarMedia: consumer declined ${s.origin} ${s.showId} for ${s.runUri} (${c.reason}); retries on the next read`),mG(e,`declined`,c.reason);return}if(c.outcome===`refused`){i.fingerprints.add(e.fingerprint),console.warn(`similarMedia: consumer refused ${s.origin} ${s.showId} for ${s.runUri} (${c.reason}); re-asks on new evidence`),mG(e,`refused`,c.reason);continue}let l=c.outcome===`containing`?`containing`:`answered`,u=l===`containing`?`PART_OF`:`SAME_AS`,d=(await gG(s.runUri)).find(e=>e.origin===s.origin);if(d){i.settled=!0,d.uri===c.media.uri?(console.warn(`similarMedia: consumer ${l===`containing`?`contradicted`:`settled`} ${s.origin} ${s.showId} for ${s.runUri} (${d.uri} is already the cluster's ${s.origin} run, claimed ${u})`),await hG(s,c.media,u),mG(e,l,c.media.uri)):(console.warn(`similarMedia: consumer refused-by-origin ${c.media.uri} for ${s.runUri} (${d.uri} is already the cluster's ${s.origin} run)`),mG(e,`refused`,`other-run`));return}let f=o.titles??[],p=(c.media.titles??[]).map(e=>e.title),m=await aO(f,p);if(!m.ok){i.refusedTitles.add(e.titles),console.warn(`similarMedia: consumer refused-by-title ${c.media.uri} for ${s.runUri} (best ${m.score.toFixed(3)} of ${f.length} run titles against ${p.length} answer titles, threshold ${iO}); re-asks on a new title`),mG(e,`refused`,`by-title`);continue}i.settled=!0,u===`SAME_AS`&&await ER([],[{mediaUri:s.runUri,handleUri:c.media.uri,relation:u}]),await hG(s,c.media,u),console.warn(`similarMedia: consumer claimed ${c.media.uri} as ${u} of ${s.runUri}`),mG(e,l,c.media.uri);return}}catch(e){console.error(Error(`similarMedia consumer failed`,{cause:e})),a&&mG(a,`error`,e instanceof Error?e.message:String(e))}finally{for(let t=e;t;t=t.mergedInto)t.driver===r&&(t.driver=void 0)}},CG=async(e,t,n)=>{try{if(!RA({context:t}).crossSource)return;let r=_G(e);if(!r)return;let i=zV()&&XH()===`graph`?new Set((await gG(r)).map(e=>e.origin)):void 0,a=yG(e,jR(e),n.implemented,i);if(!a.length)return;let o=await BR(e.map(e=>e.uri)),s=xG(e,o.flat().flatMap(e=>(e.titles??[]).map(e=>e.title)));if(!PD(s))return;let c=YS(e.map(e=>e.uri));await Promise.all(a.map(r=>{let i=dG(r.containerUri,e);if(!i.settled){if(!s.titles?.length){i.skipLogged||(i.skipLogged=!0,console.warn(`similarMedia: consumer skipped ${r.origin} ${r.showId} for ${r.runUri} (no run titles to verify the show against)`));return}return i.latest=pG(r,s,c),SG(i,t,n)}}))}catch(e){console.error(Error(`similarMedia consumer failed`,{cause:e}))}},wG=e=>new Set((e??[]).map(e=>e.toLowerCase())),TG=(e,t)=>{let n=t.categories??[],r=t.formats??[],i=wG(t.genres),a=wG(t.tags),{status:o,season:s,seasonYear:c}=t;return e.filter(e=>{if(n.length&&!(e.categories??[]).some(e=>n.includes(e))||r.length&&!(e.type&&r.includes(e.type))||o&&e.status!==o||s&&e.season!==s||c&&e.seasonYear!==c)return!1;if(i.size){let t=wG(e.genres);for(let e of i)if(!t.has(e))return!1}if(a.size){let t=wG(e.tags);for(let e of a)if(!t.has(e))return!1}return!0})},EG=(e,t,n)=>e==null?t==null?0:1:t==null?-1:(e-t)*n,DG=(e,t)=>{let n=[...e];for(let e of t??[])e===`POPULARITY`?n.sort((e,t)=>EG(e.popularity,t.popularity,1)):e===`POPULARITY_DESC`&&n.sort((e,t)=>EG(e.popularity,t.popularity,-1));return n},OG=new Set([`TV`,`MOVIE`,`SPECIAL`,`OVA`,`ONA`]),kG=e=>e===`TV_SHORT`?`TV`:e,AG=[`specials`,`special`,`picture drama`,`recap`,`ova`,`ona`,`bonus`,`mini anime`,`episode 0`,`trailer`],jG=e=>mT(e).replace(/\b(?:the|a|an)\b/g,` `).replace(/\s+/g,` `).trim(),MG=/\p{L}/u,NG=e=>MG.test(e)&&!Jw(e),PG=(e,t)=>e<t?-1:+(e>t),FG=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.getUTCFullYear()},IG=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())||t.getUTCDate()===1?null:Math.floor(t.getTime()/864e5)},LG=(e,t)=>{for(let[n,r]of[[e,t],[t,e]])for(let e of n)for(let t of AG)if(!(e.length<=t.length+1||!e.endsWith(` ${t}`))&&r.includes(e.slice(0,-(t.length+1)).trim()))return!0;return!1},RG=e=>[...e].sort(PG),zG=e=>{let t=new Map;for(let n of e)for(let{title:e,score:r}of n.titles??[]){let n=jG(e);if(!NG(n))continue;let i=r??-1,a=t.get(n);(a===void 0||i>a)&&t.set(n,i)}return BG(t)},BG=e=>{let t=new Map;for(let[n,r]of e){let e=t.get(r);e?e.push(n):t.set(r,[n])}return[...t].sort(([e],[t])=>t-e).flatMap(([,e])=>RG(e)).slice(0,6)},VG=e=>{let t=e.map(e=>e.uri).sort()[0],n=e.every(e=>e.scope===`CONTAINER`)?`CONTAINER`:`RUN`,r=e.filter(e=>(e.scope===`CONTAINER`?`CONTAINER`:`RUN`)===n).map(e=>e.uri).sort()[0]??t,i=zG(e),a=new Set(e.map(e=>FG(e.startDate)).filter(e=>e!==null)),o=new Set(e.map(e=>IG(e.startDate)).filter(e=>e!==null)),s=new Set(e.flatMap(e=>{let t=kG(e.type);return t===`SPECIAL`||t===`OVA`||t===`ONA`?[]:[...e.categories??[],...t===`MOVIE`?[`MOVIE`]:t===`TV`?[`SERIES`]:[]]}).filter(e=>e===`MOVIE`||e===`SERIES`)),c=new Set(e.map(e=>kG(e.type)).filter(e=>e!==null&&OG.has(e))),l=new Set(e.flatMap(e=>e.titles??[]).map(({title:e})=>Yw(e)).filter(e=>e!==void 0));return{cluster:e,key:t,scope:n,linkUri:r,titles:i,years:a,days:o,formats:s,types:c,seasons:l,cacheKey:`${t}#${[...i].sort(PG).join(`,`)}#${[...s].sort(PG).join(`,`)}#${[...l].sort((e,t)=>e-t).join(`,`)}#${[...o].sort((e,t)=>e-t).join(`,`)}#${[...c].sort(PG).join(`,`)}`}},HG=(e,t)=>{let n=new Map;for(let t of e)n.set(t,(n.get(t)??0)+1);let r=0;for(let e of t){let t=n.get(e)??0;t>0&&(n.set(e,t-1),r++)}return r/Math.max(e.length,t.length)},UG=e=>{let t=/^(.*?)\s*(\d+)$/.exec(e);return t?{stem:t[1],value:Number(t[2])}:{stem:e,value:null}},WG=(e,t)=>{let n=UG(e),r=UG(t);return n.value!==r.value&&n.stem===r.stem},GG=async(e,t)=>{if(e.formats.size&&t.formats.size&&![...e.formats].some(e=>t.formats.has(e))||e.seasons.size&&t.seasons.size&&![...e.seasons].some(e=>t.seasons.has(e))||e.days.size&&t.days.size&&![...e.days].some(e=>[...t.days].some(t=>Math.abs(e-t)<=45))||e.types.size&&t.types.size&&![...e.types].some(e=>t.types.has(e))&&LG(e.titles,t.titles))return!1;for(let n of e.titles)for(let e of t.titles)if(n===e||!WG(n,e)&&!(HG(n,e)<.9)&&await ET(n,e)>=.9)return!0;return!1},KG=(e,t)=>e.cacheKey<t.cacheKey?`${e.cacheKey}|${t.cacheKey}`:`${t.cacheKey}|${e.cacheKey}`,qG=new Map,JG=async(e,t)=>{let n=KG(e,t),r=qG.get(n);if(r!==void 0)return r;let i=await GG(e,t);return qG.set(n,i),i},YG=async e=>{let t=e.filter(e=>e.length).map(VG),n=new Map;for(let e of t)if(e.titles.length)for(let t of e.years){let r=n.get(t);r?r.push(e):n.set(t,[e])}qG.size>5e4&&qG.clear();let r=[],i=new Set;for(let e of n.values())for(let t=0;t<e.length;t++)for(let n=t+1;n<e.length;n++){let a=e[t],o=e[n],s=KG(a,o);i.has(s)||(i.add(s),await JG(a,o)&&r.push(a.linkUri<o.linkUri?[a.linkUri,o.linkUri]:[o.linkUri,a.linkUri]))}r.sort(([e,t],[n,r])=>PG(e,n)||PG(t,r));let a=!1;for(let[e,t]of r){let n=await AR(e),r=await AR(t);if(!n.length||!r.length)continue;let i=VG(n),o=VG(r);if(i.key!==o.key&&await JG(i,o))if(i.scope!==o.scope){let[e,t]=i.scope===`RUN`?[i.linkUri,o.linkUri]:[o.linkUri,i.linkUri];kR([[e,t]])&&(a=!0)}else i.scope===`CONTAINER`?OR([[e,t]])&&(a=!0):DR([[e,t]])&&(a=!0)}return a},XG=864e5,ZG=/\p{L}/u,QG=/^\d{4}-\d{2}-\d{2}$/,$G=e=>{if(!(typeof e!=`string`||!e))try{return JSON.parse(e)}catch{return}},eK=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:{},tK=(e,t)=>typeof e[t]==`string`&&e[t]?e[t]:void 0,nK=e=>{let t=new Map;for(let n of Array.isArray(e)?e:[]){if(!n||typeof n.title!=`string`)continue;let e=typeof n.class==`string`&&n.class?n.class:`MAIN`;if(e!==`MAIN`)continue;let r=mT(n.title);if(!r||!ZG.test(r)||Jw(r))continue;let i=typeof n.score==`number`&&Number.isFinite(n.score)?n.score:null,a=typeof n.language==`string`?n.language:null,o=t.get(r);o&&(o.score??-1)>=(i??-1)||t.set(r,{key:r,score:i,language:a,class:e})}return[...t.values()].sort((e,t)=>(t.score??-1)-(e.score??-1)||(e.key<t.key?-1:+(e.key>t.key)))},rK=e=>{let t=new Map;for(let n of e){let e=n.key.normalize(`NFD`).replace(/\p{M}/gu,``),r=t.get(e);r&&(r.score??-1)>=(n.score??-1)||t.set(e,{...n,key:e})}return[...t.values()]},iK=new Set(`with.from.into.were.been.they.them.their.this.that.when.then.than.what.which.while.where.after.before.have.over.will.would.could.should.there.about.also.only.more.most.some.such.very.just.these.those.upon.onto.because.through.during.against.between.again.once.both.each`.split(`.`)),aK=e=>{let t=[...new Set(mT(e).split(` `).filter(e=>e.length>=4&&!iK.has(e)))].sort();return t.length>=5?t.join(` `):``},oK=(e,t)=>{let n=new Map,r=(e,t)=>{for(let r of Array.isArray(e)?e:[]){if(!r||typeof r[t]!=`string`)continue;let e=aK(r[t]);if(!e)continue;let i=typeof r.score==`number`&&Number.isFinite(r.score)?r.score:null,a=typeof r.language==`string`?r.language:null,o=n.get(e);o&&(o.score??-1)>=(i??-1)||n.set(e,{key:e,score:i,language:a})}};return r(e,`description`),r(t,`shortDescription`),[...n.values()].sort((e,t)=>(t.score??-1)-(e.score??-1)||(e.key<t.key?-1:+(e.key>t.key)))},sK=e=>{let t={seasonOrdinal:null,partOrdinal:null,ordinalFrom:null};for(let n of Array.isArray(e)?e:[]){if(!n||typeof n.title!=`string`)continue;let e=n.title,r=e.search(zD),i=Yw(r<0?e:e.slice(0,r));if(i!==void 0&&t.seasonOrdinal===null&&(t.seasonOrdinal=i,t.ordinalFrom=e),r<0||!LD(e))continue;let a=Yw(e.slice(r));a!==void 0&&t.partOrdinal===null&&(t.partOrdinal=a,t.ordinalFrom??=e)}return t},cK=(e,t,n)=>{if(typeof e!=`string`||!e)return{datePrecision:`none`,startDay:null,year:null,dateDerivation:null};let r=new Date(e);if(Number.isNaN(r.getTime()))return{datePrecision:`none`,startDay:null,year:null,dateDerivation:null};let i=r.getUTCFullYear(),a=r.getUTCDate()===1,o=t===`day`||t===`month-or-year`||t===`none`?t:a?`month-or-year`:`day`,s=n===`published`||n===`coerced`||n===`declared`?n:t?`declared`:a?`coerced`:`published`;return{datePrecision:o,startDay:o===`day`?Math.floor(r.getTime()/XG):null,year:i,dateDerivation:s}},lK=(e,t)=>{let n=kG(typeof e==`string`?e:null);if(n===`SPECIAL`||n===`OVA`||n===`ONA`||!n)return null;let r=new Set;for(let e of Array.isArray(t)?t:[])(e===`MOVIE`||e===`SERIES`)&&r.add(e);return n===`MOVIE`&&r.add(`MOVIE`),n===`TV`&&r.add(`SERIES`),r.size===1?[...r][0]:null},uK=e=>{let t=kG(typeof e==`string`?e:null);return t&&OG.has(t)?t:null},dK=e=>{for(let t of Array.isArray(e)?e:[]){if(!t||typeof t.title!=`string`)continue;let e=mT(t.title);for(let t of AG)if(e.length>t.length+1&&e.endsWith(` ${t}`))return!0}return!1},fK=e=>{let t=e.indexOf(`:`);if(t<=0)return;let n=e.slice(t+1),r=n.lastIndexOf(`-`);if(!(r<=0||r===n.length-1))return`${e.slice(0,t+1)}${n.slice(0,r)}`},pK=e=>{let t=[];e.showLevel&&t.push(`showLevelOrigin`);for(let n of e.answersSaid)n.said===`CONTAINER`&&t.push(`answer:${n.origin}`);e.owned&&e.stamp===`CONTAINER`&&t.push(`row`);let n=e.owned;for(let r of e.claims)r.provenance!==`source`&&r.provenance!==`ask`||(r.targetScope===`CONTAINER`&&t.push(`claim:${String(r.claimer)}`),r.targetScope===`RUN`&&(n=!0));let r=[...new Set(t)].sort();return r.length?{scope:`CONTAINER`,scopeFrom:r}:{scope:n?`RUN`:null,scopeFrom:[]}},mK=(e,t,n,r)=>{let i=typeof t==`number`&&Number.isSafeInteger(t)?t:null,a=n>0?n:null;return{countKind:r===`declared`||r===`listLength`||r===`none`?r:i===null?`none`:sW.has(e)?`declared`:`listLength`,countStated:i,countDistinct:a}},hK=e=>{if(typeof e!=`string`||!e)return{day:null,dayPrecision:`none`};let t=Date.parse(e);return Number.isFinite(t)?{day:Math.floor(t/XG),dayPrecision:QG.test(e)?`day`:`instant`}:{day:null,dayPrecision:`none`}},gK=e=>typeof e!=`string`||!e||e===`null`?null:e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e,_K=async(e,t)=>{let n=t!==void 0,r=n?{uris:t}:void 0,i=n&&!t.length,a=(e,t,r)=>n?`UNWIND $uris AS u MATCH (${e} {uri: u})${t} ${r}`:`MATCH (${e})${t} ${r}`;return{media:i?[]:await e.query(a(`m:Media`,``,`RETURN m.uri AS uri, m.raw AS raw, m.owned AS owned, m.scope AS scope, m.origin AS origin,
1504
+ m.id AS id, m.type AS type, m.startDate AS startDate, m.episodeCount AS episodeCount,
1505
+ m.titles AS titles, m.categories AS categories`),r),claims:i?[]:await e.query(a(`m:Media`,`<-[c:CLAIMS]-(:Media)`,`RETURN m.uri AS uri, collect(DISTINCT {kind: c.kind, targetScope: c.targetScope, claimer: c.claimer, provenance: c.provenance}) AS claims`),r),said:i?[]:await e.query(a(`m:Media`,`<-[:ABOUT]-(a:Answer)`,`RETURN m.uri AS uri, collect(DISTINCT {origin: a.origin, said: json_extract(a.raw, 'scope')}) AS said`),r),owns:i?[]:await e.query(a(`m:Media`,`-[h:HAS_EPISODE]->(e:Episode)`,`WHERE h.claimer = m.origin RETURN m.uri AS uri, count(DISTINCT e.uri) AS ownEpisodes`),r),episodes:i?[]:await e.query(a(`e:Episode`,``,`RETURN e.uri AS uri, e.origin AS origin, e.releaseDate AS releaseDate, e.titles AS titles, e.raw AS raw`),r)}},vK=async(e,t)=>{if(!t.length)return[];let n=await e.query(`UNWIND $keys AS k MATCH (a:Media)-[c:CLAIMS {key: k}]->(b:Media)
1506
+ RETURN a.uri AS fromUri, b.uri AS toUri`,{keys:t});return[...new Set(n.flatMap(e=>[e.fromUri,e.toUri]))]},yK=async e=>[...new Set([...e.delta.media,...e.delta.episodes,...await vK(e,e.delta.claims)])],bK=(e,t,n,r)=>{let i=eK($G(e.raw)),a=$G(e.titles)??i.titles,o=iW.has(e.origin),{scope:s,scopeFrom:c}=pK({owned:e.owned,stamp:e.scope,showLevel:o,claims:t,answersSaid:n}),l=nK(a),u=sK(a),d=cK(e.startDate??i.startDate,tK(i,`startDatePrecision`),tK(i,`startDateDerivation`)),f=mK(e.origin,e.episodeCount,r,tK(i,`episodeCountKind`)),p=tK(i,`startDateSubject`)??(s===`RUN`?`run`:`container`);return{keys:l,profile:{uri:e.uri,scope:s,scopeFrom:c,dateSubject:p,titleKeys:l,titleKeysFolded:rK(l),seasonOrdinal:u.seasonOrdinal,partOrdinal:u.partOrdinal,ordinalFrom:u.ordinalFrom,year:d.year,startDay:d.startDay,datePrecision:d.datePrecision,dateDerivation:d.dateDerivation,format:lK(e.type??i.type,e.categories??i.categories),workKind:uK(e.type??i.type),companion:dK(a),countKind:f.countKind,countStated:f.countStated,countDistinct:f.countDistinct,folding:aW.has(e.origin),retranslates:oW.has(e.origin),showLevelOrigin:o,idParent:null}}},xK=(e,t)=>{let n=eK($G(e.raw)),r=$G(e.titles)??n.titles,i=Array.isArray(r)?r:[],a=hK(e.releaseDate??n.releaseDate),o=tK(n,`episodeNumberSpace`);return{uri:e.uri,day:a.day,dayPrecision:a.dayPrecision,numberSpace:o??cW[e.origin]??`season`,titleKeys:nK(r).filter(e=>!t.isGenericEpisodeTitle(e.key)),synopsisKeys:oK(n.descriptions,n.shortDescriptions),generic:!i.length||i.every(e=>typeof e.title!=`string`||t.isGenericEpisodeTitle(e.title))}},SK={id:`plugin:profile`,consumes:{nodes:[`Media`,`Episode`,`Answer`],edges:[`ABOUT`,`CLAIMS`,`HAS_EPISODE`]},produces:{nodes:[`MediaProfile`,`EpisodeProfile`,`TitleKey`],edges:[`PROFILE_OF`,`HAS_KEY`]},after:[],version:2,run:async e=>{let t=e.delta.full?void 0:await yK(e),{media:n,claims:r,said:i,owns:a,episodes:o}=await _K(e,t),s=new Map(r.map(e=>[e.uri,e.claims??[]])),c=new Map(i.map(e=>[e.uri,(e.said??[]).map(e=>({origin:e.origin,said:gK(e.said)}))])),l=new Map(a.map(e=>[e.uri,Number(e.ownEpisodes??0)])),u=[],d=[],f=new Map,p=new Map;for(let e of n){let{profile:t,keys:n}=bK(e,s.get(e.uri)??[],c.get(e.uri)??[],l.get(e.uri)??0);u.push(t);let r=fK(e.uri);r&&p.set(e.uri,r);for(let t of n)f.set(t.key,{key:t.key}),d.push({from:e.uri,to:t.key,key:t.key,score:t.score,language:t.language,class:t.class})}if(p.size){let t=new Set((await e.query(`UNWIND $uris AS u MATCH (m:Media {uri: u}) RETURN m.uri AS uri`,{uris:[...new Set(p.values())]})).map(e=>e.uri));for(let e of u){let n=p.get(e.uri);n&&t.has(n)&&(e.idParent=n)}}let m=o.map(t=>xK(t,e));return{scope:t===void 0?{full:!0}:{full:!1,uris:t,clusters:[],pairs:[]},nodes:[{table:`MediaProfile`,rows:u},{table:`EpisodeProfile`,rows:m},{table:`TitleKey`,rows:[...f.values()]}],edges:[{table:`PROFILE_OF`,rows:[...u.map(e=>({from:e.uri,to:e.uri})),...m.map(e=>({from:e.uri,to:e.uri}))]},{table:`HAS_KEY`,rows:d}],links:[],episodeLinks:[]}}},CK=new Set([`cross-scope`,`disagreeing-ids`,`contested`,`count-mismatch`,`no-length`,`kind-mismatch`]),wK=e=>e===!0,TK=e=>typeof e==`string`&&e?e:null,EK=e=>e==null?null:Number.isFinite(Number(e))?Number(e):null,DK=e=>e.slice(0,e.indexOf(`:`)),OK=e=>e.slice(e.indexOf(`:`)+1),kK=/^([a-z]+)-\d+$/,AK=e=>{let t=DK(e);if(t!==`offline`)return t;let n=kK.exec(OK(e));return n?`offline/${n[1]}`:t},jK=e=>({uri:e,origin:DK(e),scope:null,idParent:null,folding:!1,countStated:null,countDistinct:null,format:null,showLevelOrigin:!1,status:null,clusterRunLength:null}),MK=(e,t,n)=>{if(e===t)return!0;if(DK(e)!==DK(t))return!1;let r=(e,t)=>{let r=e;for(let e=0;e<8&&r;e+=1)if(r=n(r),r===t)return!0;return!1};return r(e,t)||r(t,e)?!0:OK(e).startsWith(`${OK(t)}-`)||OK(t).startsWith(`${OK(e)}-`)},NK=(e,t,n)=>{let r=new Set(t);for(let i of[...new Set(e)].sort())if(!r.has(i)){for(let e of[...new Set(t)].sort())if(AK(i)===AK(e)&&!MK(i,e,n))return[i,e]}};let PK=0,FK,IK=!1;const LK=()=>{PK+=1,FK=void 0},RK=async e=>{if(IK||(IK=!0,MV(LK)),FK&&FK.epoch===PK)return FK.value;let t=PK,n=await zK(e);return PK===t&&(FK={epoch:t,value:n}),n},zK=async e=>{let t=new Map,n=e=>{let n=e;for(;t.get(n)&&t.get(n)!==n;)n=t.get(n);let r=e;for(;t.get(r)&&t.get(r)!==r;){let e=t.get(r);t.set(r,n),r=e}return n},r=(e,r)=>{t.set(e,t.get(e)??e),t.set(r,t.get(r)??r);let i=n(e),a=n(r);i!==a&&(i<a?t.set(a,i):t.set(i,a))},i=await e(`MATCH (a:Media)-[l:LINK]->(b:Media)
1507
+ WHERE l.kind = 'SAME_AS' AND l.status = 'active'
1508
+ RETURN a.uri AS fromUri, b.uri AS toUri`),a=new Map,o=(e,t)=>{let n=a.get(e);n?n.push(t):a.set(e,[t])};for(let e of i){let t=[String(e.fromUri),String(e.toUri)];o(t[0],t),o(t[1],t),r(t[0],t[1])}let s=new Map;for(let e of t.keys()){let t=n(e),r=s.get(t);r?r.push(e):s.set(t,[e])}let c=e=>t.has(e)?n(e):e,l=e=>t.has(e)?[...s.get(n(e))].sort():[e],u=new Map;return{keyOf:c,membersOf:l,without:e=>{let t=typeof e==`string`?new Set([e]):new Set(e),n=[...t].sort().join(`\0`),r=u.get(n);if(r)return r;let i=new Set;for(let e of t)for(let t of l(e))i.add(t);let o=new Map,s=e=>{let t=e;for(;o.get(t)&&o.get(t)!==t;)t=o.get(t);return t};for(let e of i)t.has(e)||o.set(e,e);let d=new Set;for(let e of i)if(!t.has(e))for(let n of a.get(e)??[]){if(d.has(n))continue;d.add(n);let[e,r]=n;if(t.has(e)||t.has(r))continue;let i=s(e),a=s(r);i!==a&&(i<a?o.set(a,i):o.set(i,a))}let f=new Map;for(let e of o.keys()){let t=s(e),n=f.get(t);n?n.push(e):f.set(t,[e])}let p={keyOf:e=>o.has(e)?s(e):t.has(e)?e:c(e),membersOf:e=>o.has(e)?[...f.get(s(e))].sort():t.has(e)?[e]:l(e)};return u.set(n,p),p}}},BK=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},VK=2e3,HK=async(e,t)=>{let n=new Set,r=new Set;for(let e of t){n.add(e.fromUri),n.add(e.toUri);for(let t of e.supports)r.add(t)}let i=await RK(e),a=new Set(n);for(let e of n)for(let t of i.membersOf(e))a.add(t);let o=new Map;for(let t of BK([...a],VK)){if(!t.length)continue;let n=await e(`UNWIND $uris AS u
1509
+ MATCH (a:Media)-[c:CLAIMS]->(b:Media {uri: u})
1510
+ WHERE c.kind = 'SAME_AS' AND c.provenance <> 'address'
1511
+ RETURN DISTINCT u AS target, a.uri AS claimant, c.claimer AS claimer ORDER BY target, claimant, claimer`,{uris:t});for(let e of n){let t=String(e.target),n=o.get(t)??[];n.push({claimant:String(e.claimant),claimer:String(e.claimer)}),o.set(t,n)}}let s=new Set(n);for(let e of n){for(let t of i.membersOf(e))s.add(t);for(let t of o.get(e)??[]){s.add(t.claimant);for(let e of i.membersOf(t.claimant))s.add(e)}}let c=new Map;for(let t of BK([...s],VK)){if(!t.length)continue;let n=await e(`UNWIND $uris AS u
1512
+ MATCH (p:MediaProfile {uri: u}), (m:Media {uri: u})
1513
+ RETURN p.uri AS uri, m.origin AS origin, p.scope AS scope, p.idParent AS idParent,
1514
+ p.folding AS folding, p.countStated AS countStated, p.countDistinct AS countDistinct,
1515
+ p.format AS format, p.showLevelOrigin AS showLevelOrigin, m.status AS status`,{uris:t});for(let e of n){let t=String(e.uri);c.set(t,{uri:t,origin:TK(e.origin)??DK(t),scope:TK(e.scope)===`CONTAINER`?`CONTAINER`:TK(e.scope)===`RUN`?`RUN`:null,idParent:TK(e.idParent),folding:wK(e.folding),countStated:EK(e.countStated),countDistinct:EK(e.countDistinct),format:TK(e.format),showLevelOrigin:wK(e.showLevelOrigin),status:TK(e.status),clusterRunLength:null})}}for(let t of BK([...s],VK)){if(!t.length)continue;let n=await e(`UNWIND $uris AS u MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster)
1516
+ RETURN u AS uri, c.runLength AS runLength`,{uris:t});for(let e of n){let t=c.get(String(e.uri));t&&(t.clusterRunLength=EK(e.runLength))}}let l=new Set;for(let t of BK([...r],VK)){if(!t.length)continue;let n=await e(`UNWIND $keys AS k MATCH (a:Media)-[c:CLAIMS {key: k}]->(b:Media)
1517
+ WHERE c.provenance = 'address' RETURN DISTINCT c.key AS key`,{keys:t});for(let e of n)l.add(String(e.key))}let u=new Set,d=t.map(e=>({a:e.fromUri,b:e.toUri}));for(let t of BK(d,VK)){if(!t.length)continue;let n=await e(`UNWIND $pairs AS p
1518
+ MATCH (a:Media {uri: p.a})-[l:LINK {status: 'active'}]-(b:Media {uri: p.b})
1519
+ WHERE l.kind IN ['PART_OF', 'INCLUDES']
1520
+ RETURN DISTINCT p.a AS a, p.b AS b, l.reason AS reason`,{pairs:t});for(let e of n)CK.has(String(e.reason))||u.add(UK(String(e.a),String(e.b)))}let f=e=>c.get(e)??jK(e),p=e=>c.get(e)?.idParent??null,m=new Map;for(let[e,t]of o)for(let n of t){let t=m.get(n.claimant);t?t.add(e):m.set(n.claimant,new Set([e]))}let h=GK(o,m,i,p);return{profileOf:f,components:i,sameAs:e=>ZK(e,{profileOf:f,parentOf:p,components:i,claimsInto:o,addressKeys:l,contained:u,sites:h,claims:m}),partOf:(e,t)=>QK(e,t,f)}},UK=(e,t)=>e<t?`${e}\u0000${t}`:`${t}\u0000${e}`,WK=(e,t,n,r)=>{let i=[...r.get(e)??[]].filter(e=>r.get(t)?.has(e));return i.length?i:n},GK=(e,t,n,r)=>{let i=[];for(let[a,o]of e){let e=[...new Set(o.map(e=>e.claimant))].filter(e=>e!==a).sort();if(e.length<2)continue;let s=new Set,c=!1;for(let i=0;i<e.length;i+=1)for(let o=i+1;o<e.length;o+=1){let l=n.without(WK(e[i],e[o],a,t));s.add(l.keyOf(e[i])),s.add(l.keyOf(e[o])),!c&&l.keyOf(e[i])!==l.keyOf(e[o])&&NK(l.membersOf(e[i]),l.membersOf(e[o]),r)&&(c=!0)}i.push({target:a,claimants:e,keys:s,standing:c})}return i},KK=(e,t,n)=>{let r=new Set;for(let i of n.sites){let{claimants:a}=i,o=n.components.without(WK(a[0],a[1],i.target,n.claims)),s=o.keyOf(e),c=o.keyOf(t);if(s===c||!i.keys.has(s)&&!i.keys.has(c)){i.standing&&r.add(i.target);continue}for(let o=0;o<a.length&&!r.has(i.target);o+=1)for(let s=o+1;s<a.length;s+=1){let c=n.components.without(WK(a[o],a[s],i.target,n.claims)),l=c.keyOf(e),u=c.keyOf(t),d=l<u?l:u,f=[...new Set([...c.membersOf(e),...c.membersOf(t)])].sort(),p=e=>{let t=c.keyOf(e);return t===l||t===u?d:t},m=e=>{let t=c.keyOf(e);return t===l||t===u?f:c.membersOf(e)};if(p(a[o])!==p(a[s])&&NK(m(a[o]),m(a[s]),n.parentOf)){r.add(i.target);break}}}return r},qK=e=>e.countDistinct??e.countStated,JK=e=>e.clusterRunLength??qK(e),YK=(e,t)=>{if(e.scope!==t.scope)return e.scope===`CONTAINER`?e:t;let n=qK(e),r=qK(t);return n!==null&&r!==null&&n!==r?n>r?e:t:e.showLevelOrigin===t.showLevelOrigin?e.uri>t.uri?e:t:e.showLevelOrigin?e:t},XK=(e,t,n,r)=>({fromUri:t.uri,toUri:e.uri,reason:n,evidence:r}),ZK=(e,t)=>{let n=t.profileOf(e.fromUri),r=t.profileOf(e.toUri);if(n.scope===null||r.scope===null)return{ok:!1,reason:`unknown-scope`,write:!1,evidence:{theirs:r.scope,ours:n.scope}};if(n.scope!==r.scope){let e=n.scope===`CONTAINER`?n:r,t=e===n?r:n;return{ok:!1,reason:`cross-scope`,write:!0,evidence:{theirs:e.scope,ours:t.scope},downgrade:XK(e,t,`cross-scope`,{theirs:e.scope,ours:t.scope})}}let i=e.supports.filter(e=>t.addressKeys.has(e));if(i.length)return{ok:!1,reason:`address-only`,write:!0,evidence:{theirs:i,ours:e.supports}};let a=KK(n.uri,r.uri,t),o=a.size?t.components.without(a):t.components,s=o.membersOf(n.uri),c=o.membersOf(r.uri);if(o.keyOf(n.uri)!==o.keyOf(r.uri)){let e=NK(s,c,t.parentOf);if(e){let[t,i]=e,a=n.uri===t&&r.uri!==i?r:r.uri===i&&n.uri!==t?n:YK(n,r);return{ok:!1,reason:`disagreeing-ids`,write:!0,evidence:{theirs:i,ours:t},downgrade:XK(a,a===n?r:n,`disagreeing-ids`,{theirs:i,ours:t})}}}for(let e of[r,n]){let i=e===n?r:n,a=[...new Set((t.claimsInto.get(e.uri)??[]).map(e=>e.claimant))].filter(t=>t!==e.uri).sort();if(!(a.length<2))for(let n=0;n<a.length;n+=1)for(let r=n+1;r<a.length;r+=1){let o=[...t.claims.get(a[n])??[]].filter(e=>t.claims.get(a[r])?.has(e)),s=t.components.without(o.length?o:e.uri),c=s.keyOf(i.uri),l=s.membersOf(a[n]),u=s.membersOf(a[r]);if(s.keyOf(a[n])===s.keyOf(a[r]))continue;let d=NK(l,u,t.parentOf);if(!d)continue;let f=s.keyOf(a[n])===c,p=s.keyOf(a[r])===c;if(!f&&!p)continue;let m={theirs:f?d[1]:d[0],ours:f?d[0]:d[1]};return{ok:!1,reason:`contested`,write:!0,evidence:m,downgrade:XK(e,i,`contested`,m)}}}if(t.contained.has(UK(n.uri,r.uri)))return{ok:!1,reason:`contained`,write:!0,evidence:{theirs:r.uri,ours:n.uri}};let l=n.folding&&r.folding?YK(n,r):n.folding?n:r.folding?r:null;if(l){let e=l===n?r:n,t=qK(l),i=JK(e);if(t!==null&&i!==null&&t!==i){let n=t>i?l:e,r=n===l?e:l;if(t>i||e.status===`FINISHED`)return{ok:!1,reason:`count-mismatch`,write:!0,evidence:{theirs:t,ours:i},downgrade:XK(n,r,`count-mismatch`,{theirs:t,ours:i})}}if(i===null)return{ok:!1,reason:`no-length`,write:!0,evidence:{theirs:t,ours:i},downgrade:XK(l,e,`no-length`,{theirs:t,ours:i})}}if(n.format&&r.format&&n.format!==r.format&&(n.format===`MOVIE`||r.format===`MOVIE`)){let e=YK(n,r),t=e===n?r:n,i={theirs:e.format,ours:t.format};return{ok:!1,reason:`kind-mismatch`,write:!0,evidence:i,downgrade:XK(e,t,`kind-mismatch`,i)}}return{ok:!0}},QK=(e,t,n)=>{if(e===t)return{ok:!1,reason:`self`,write:!0,evidence:{theirs:t,ours:e}};let r=n(e),i=n(t);return r.scope===null||i.scope===null?{ok:!1,reason:`unknown-scope`,write:!1,evidence:{theirs:i.scope,ours:r.scope}}:r.scope===`CONTAINER`&&i.scope===`RUN`?{ok:!1,reason:`inverted`,write:!0,evidence:{theirs:i.scope,ours:r.scope}}:{ok:!0}},$K=e=>{if(typeof e!=`string`||!e)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t?t:{}}catch{return{}}},eq=async e=>{let t=await RK(e),n=await e(`MATCH (p:MediaProfile) RETURN p.uri AS uri, p.idParent AS idParent`),r=new Map;for(let e of n)r.set(String(e.uri),typeof e.idParent==`string`?e.idParent:null);let i=e=>r.get(e)??null,a=[],o=new Set;for(let e of r.keys()){let n=t.keyOf(e);if(o.has(n))continue;o.add(n);let r=t.membersOf(e);if(!(r.length<2))for(let e=0;e<r.length;e+=1)for(let t=e+1;t<r.length;t+=1){let n=r[e],o=r[t];AK(n)===AK(o)&&(MK(n,o,i)||a.push({rule:`disagreeing-ids`,detail:`${n} and ${o} are two ids of ${AK(n)} in one component, and neither extends the other`,uris:[...r]}))}}let s=await e(`MATCH (a:Media)-[l:LINK]->(b:Media)
1521
+ WHERE l.status = 'refused' AND l.reason = 'disagreeing-ids'
1522
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.evidence AS evidence ORDER BY fromUri, toUri`);for(let e of s)a.push({rule:`disagreeing-ids`,detail:`${String(e.fromUri)} was refused sameness with ${String(e.toUri)}: ${String(e.evidence??`{}`)}`,uris:[String(e.fromUri),String(e.toUri)]});return a},tq=async e=>{let t=await e(`MATCH (a:Media)-[l:LINK]->(b:Media)
1523
+ WHERE l.kind = 'PART_OF' AND l.status = 'active' AND l.reason = 'contested'
1524
+ RETURN b.uri AS target, a.uri AS claimant ORDER BY target, claimant`),n=new Map;for(let e of t){let t=String(e.target);n.set(t,[...new Set([...n.get(t)??[],String(e.claimant)])])}return[...n].filter(([,e])=>e.length>=2).map(([e,t])=>({rule:`contested`,detail:`${e} is claimed by ${t.length} components that disagree: ${t.join(`, `)}`,uris:[e,...t]}))},nq=async e=>{let t=await e(`MATCH (a:Answer)-[:ABOUT]->(m:Media) WHERE a.kind = 'media'
1525
+ RETURN m.uri AS uri, a.origin AS origin, a.raw AS raw ORDER BY uri, a.seq`),n=new Map;for(let e of t){let t=$K(e.raw),r=lK(t.type,t.categories);if(!r)continue;let i=String(e.uri),a=n.get(i)??new Map;a.set(r,[...new Set([...a.get(r)??[],String(e.origin)])]),n.set(i,a)}let r=[];for(let[e,t]of[...n].sort(([e],[t])=>e<t?-1:+(e>t))){if(t.size<2)continue;let n=[...t].map(([e,t])=>`${e} from ${t.join(`, `)}`).join(` against `);r.push({rule:`kind-disagrees`,detail:`${e} is ${n}`,uris:[e]})}return r},rq=async e=>(await e(`MATCH (a:Media)-[c:CLAIMS]->(b:Media)
1526
+ WHERE c.kind = 'SAME_AS' AND c.provenance <> 'address'
1527
+ RETURN b.uri AS target, count(DISTINCT a.uri) AS claimants ORDER BY target`)).filter(e=>Number(e.claimants)>=3).map(e=>({rule:`constant-id`,detail:`${String(e.target)} is claimed the same as ${Number(e.claimants)} distinct rows`,uris:[String(e.target)]})),iq=async e=>{let t=await e(`MATCH (s:Slot)-[:SLOT_OF]->(c:Cluster)
1528
+ WHERE s.number IS NOT NULL AND c.runLength IS NOT NULL
1529
+ RETURN c.id AS cluster, c.runLength AS runLength, c.runLengthWitnesses AS witnesses,
1530
+ s.number AS number ORDER BY cluster, number`),n=new Map;for(let e of t){let t=String(e.cluster),r=Number(e.number),i=n.get(t)??{length:Number(e.runLength),witnesses:Number(e.witnesses??0),listed:0,highest:0};i.listed+=1,i.highest=Math.max(i.highest,r),n.set(t,i)}let r=[];for(let[t,i]of n){if(i.highest<=i.length)continue;let n=await e(`MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster {id: $id}) RETURN m.uri AS uri ORDER BY uri`,{id:t});r.push({rule:`over-length`,detail:`${i.listed} listed against a length of ${i.length} that ${i.witnesses} of its sources agree on`,uris:n.map(e=>String(e.uri))})}return r},aq=async e=>(await e(`MATCH (p:MediaProfile)
1531
+ WHERE p.countStated IS NOT NULL AND p.countDistinct IS NOT NULL AND p.countStated <> p.countDistinct
1532
+ RETURN p.uri AS uri, p.countStated AS stated, p.countDistinct AS listed ORDER BY uri`)).map(e=>({rule:`count-disagrees`,detail:`${String(e.uri)} states ${Number(e.stated)} episodes and lists ${Number(e.listed)} distinct ones`,uris:[String(e.uri)]})),oq=async e=>[...await eq(e),...await tq(e),...await nq(e),...await rq(e),...await iq(e),...await aq(e)],sq=[`run-id`,`season-id`,`ask`,`seed`,`source-other`,`title`],cq=new Set([`mal`,`anilist`,`kitsu`,`anizip`,`anidb`,`offline`,`simkl`]),lq=new Set([`cr`,`nf`,`jw`,`appletv`,`tmdb`,`tvmaze`]),uq=e=>e.slice(0,e.indexOf(`:`)),dq=e=>{if(!lq.has(uq(e)))return!1;let t=e.slice(e.indexOf(`:`)+1),n=t.lastIndexOf(`-`);return n>0&&n<t.length-1},fq=e=>{let t=e.evidence;if(typeof t!=`object`||!t)return;let n=t.provenance;return typeof n==`string`?n:void 0},pq=e=>{let t=fq(e);return t===`ask`?`ask`:t===`seed`?`seed`:t===`source`?cq.has(uq(e.fromUri))&&cq.has(uq(e.toUri))?`run-id`:dq(e.fromUri)||dq(e.toUri)?`season-id`:`source-other`:`title`},mq=(e,t)=>e<t?-1:+(e>t),hq=e=>[...e].sort((e,t)=>sq.indexOf(pq(e))-sq.indexOf(pq(t))||mq(e.fromUri,t.fromUri)||mq(e.toUri,t.toUri)||mq(e.kind,t.kind)||mq(e.reason,t.reason)),gq=async(e,t,n)=>{let r=await e(`MATCH (a:Media)-[l:LINK]->(b:Media)
1533
+ WHERE l.by = $by AND l.kind = 'SAME_AS' AND l.status = 'active'
1534
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.key AS key, l.reason AS reason, l.supports AS supports
1535
+ ORDER BY fromUri, toUri`,{by:t}),i=[];for(let e of r){let t=String(e.fromUri),r=String(e.toUri);n.has(`${t}\u0000${r}`)||i.push({key:String(e.key),fromUri:t,toUri:r,reason:String(e.reason??``),supports:Array.isArray(e.supports)?e.supports.map(String):[]})}return i},_q=(e,t)=>{if(t.ok)return[{fromUri:e.fromUri,toUri:e.toUri,kind:e.kind,status:`active`,reason:e.reason,confidence:e.confidence,evidence:e.evidence??null,gates:e.gates??null,range:e.range??null,supports:e.supports}];if(!t.write)return[];let n={fromUri:e.fromUri,toUri:e.toUri,kind:e.kind,status:`refused`,reason:t.reason,confidence:e.confidence,evidence:t.evidence??null,gates:e.gates??null,range:e.range??null,supports:e.supports};return t.downgrade?[n,{fromUri:t.downgrade.fromUri,toUri:t.downgrade.toUri,kind:`PART_OF`,status:`active`,reason:t.downgrade.reason,confidence:e.confidence,evidence:t.downgrade.evidence,gates:null,range:null,supports:e.supports}]:[n]},vq=(e,t,n)=>{let r=e.get(t);if(!r){e.set(t,{...n,key:t,supports:[...new Set(n.supports)].sort()});return}r.supports=[...new Set([...r.supports,...n.supports])].sort()},yq=e=>e.status===`refused`,bq=(e,t)=>{if(t.kind===`SAME_AS`)return e.sameAs(t);if(t.kind===`PART_OF`){let n=e.partOf(t.fromUri,t.toUri);return n.ok?{ok:!0}:{ok:!1,reason:n.reason,write:n.write,evidence:n.evidence}}return{ok:!0}},xq=(e,t)=>e<t?-1:+(e>t),Sq=e=>[...new Set(e)].sort(xq),Cq=e=>typeof e==`string`&&e?e:null,wq=e=>e==null?null:Number.isFinite(Number(e))?Number(e):null,Tq=e=>e.slice(0,e.indexOf(`:`)),Eq=[`containing`,`span`,`asserted`,`prefix`,`cross-scope`,`count-mismatch`,`no-length`,`kind-mismatch`,`disagreeing-ids`,`contested`,`inside`],Dq=e=>{let t=Eq.indexOf(e);return t<0?Eq.length:t},Oq=e=>{if(e.toScope===`RUN`)return`part`;if(e.fromScope===`CONTAINER`)return`show-show`;let[t]=[...e.reasons].sort((e,t)=>Dq(e)-Dq(t)||xq(e,t));return t??`asserted`},kq=e=>{let t=new Map;for(let n of e.links){if(n.kind!==`PART_OF`)continue;let r=e.clusterOf(n.fromUri),i=e.clusterOf(n.toUri);if(!r||!i||r===i)continue;let a=`${r} ${i}`,o=t.get(a)??{from:r,to:i,reasons:[],supports:[]};o.reasons.push(n.reason),o.supports.push(n.key),t.set(a,o)}return[...t.values()].map(t=>({from:t.from,to:t.to,via:Oq({fromScope:e.clusters.get(t.from)?.scope??`RUN`,toScope:e.clusters.get(t.to)?.scope??`CONTAINER`,reasons:t.reasons}),supports:Sq(t.supports)})).sort((e,t)=>xq(e.from,t.from)||xq(e.to,t.to))},Aq=e=>{let t=e.attachments.filter(t=>t.to===e.container&&t.via!==`show-show`).map(t=>e.clusters.get(t.from)).filter(e=>!!e&&e.scope===`RUN`);if(!t.length)return null;let[n]=[...t].sort((e,t)=>(e.startDay??2**53-1)-(t.startDay??2**53-1)||xq(e.key,t.key));return n.id},jq=e=>{let t=Sq(e.map(e=>e.seasonUri)),n=[...e].sort((e,t)=>xq(e.runUri,t.runUri)||xq(e.seasonUri,t.seasonUri));return t.length>1?{ok:!1,reason:`ambiguous`,candidates:n}:{ok:!0,candidates:n}},Mq=e=>{let{clusters:t,clusterOf:n}=e,r=new Map,i=new Map,a=new Map,o=new Map,s=(e,t,n)=>{e.set(t,[...e.get(t)??[],n])},c=e=>!!(e&&t.get(e)?.scope===`RUN`),l=new Map;for(let t of e.attachments)t.via!==`show-show`&&c(t.from)&&s(l,t.to,t.from);let u=new Map;for(let t of e.links)u.set(t.fromUri,[...u.get(t.fromUri)??[],t]),u.set(t.toUri,[...u.get(t.toUri)??[],t]);for(let o of e.links){let e=n(o.fromUri),u=n(o.toUri);if(o.kind===`INCLUDES`){c(u)&&u!==e&&s(i,o.fromUri,u);continue}if(c(e)&&e!==u&&s(r,o.toUri,e),u&&t.get(u)?.scope===`CONTAINER`)for(let t of l.get(u)??[])t!==e&&s(a,o.fromUri,t)}for(let[e,r]of u){let i=r.filter(t=>t.toUri===e&&t.kind===`PART_OF`&&(t.reason===`contested`||t.reason===`disagreeing-ids`));if(!i.length||i.length!==r.length)continue;let a=n(e);a&&(t.get(a)?.members.length??1)>1||o.set(e,Sq(i.map(e=>n(e.fromUri)).filter(e=>c(e))))}return{clusters:t,clusterOf:n,partTarget:r,includesSource:i,throughContainer:a,containerRuns:l,onlyContested:o}},Nq=e=>e.members.some(e=>cq.has(Tq(e))),Pq=(e,t)=>{let n=e.scope===`CONTAINER`?(t.containerRuns.get(e.id)??[]).filter(t=>t!==e.id):[],r=(t,r)=>[...n,...r.flatMap(n=>(n.get(t)??[]).filter(t=>t!==e.id))],i=[t.partTarget,t.includesSource],a=e.members.map(e=>r(e,i)),o=a.every(e=>e.length)&&a.some(e=>e.length),s=Nq(e),c=e.scope===`CONTAINER`?`CONTAINER`:!s&&o?`FOLD`:`RUN`;if(!e.owned)return{hidden:!0,hiddenBy:[],kind:c};let l=e.members.map(e=>t.onlyContested.get(e));if(l.every(e=>e?.length))return{hidden:!0,hiddenBy:Sq(l.flatMap(e=>e)),kind:c};if(s)return{hidden:!1,hiddenBy:[],kind:c};let u=[t.partTarget,t.includesSource,t.throughContainer],d=e.members.map(e=>r(e,u));return!d.length||!d.every(e=>e.length)?{hidden:!1,hiddenBy:[],kind:c}:{hidden:!0,hiddenBy:Sq(d.flat()),kind:c}},Fq=[`run-id`,`season-id`,`ask`,`seed`,`source-other`,`title`],Iq=(e,t)=>Fq.indexOf(t.className)-Fq.indexOf(e.className)||t.seq-e.seq||xq(e.key,t.key),Lq=e=>{let t=new Map,n=(e,t)=>e<t?`${e} ${t}`:`${t} ${e}`;for(let r of e.sameAs)t.set(n(r.fromUri,r.toUri),r);let r=new Set(e.containedRefusals.map(e=>n(e.fromUri,e.toUri))),i=new Map;for(let a of e.links){if(CK.has(a.reason))continue;let o=e.clusterOf(a.toUri);if(o)for(let s of e.clusters.get(o)?.members??[]){if(s===a.fromUri||s===a.toUri)continue;let e=n(a.fromUri,s),o=t.get(e);!o&&!r.has(e)||i.set(`${a.fromUri} ${s}`,{part:a.fromUri,member:s,whole:a.toUri,retracts:o?.key??``,className:o?.className??`title`,seq:o?.seq??0})}}return[...i.values()].sort((e,t)=>Iq({fromUri:e.part,toUri:e.member,key:e.retracts,className:e.className,seq:e.seq},{fromUri:t.part,toUri:t.member,key:t.retracts,className:t.className,seq:t.seq})||xq(e.part,t.part)||xq(e.member,t.member))},Rq=async e=>{let t=await e.query(`MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster)
1536
+ MATCH (p:MediaProfile)-[:PROFILE_OF]->(m)
1537
+ RETURN c.id AS id, c.scope AS scope, c.key AS key, c.runLength AS runLength,
1538
+ m.uri AS uri, m.owned AS owned, p.startDay AS startDay, p.folding AS folding,
1539
+ p.countStated AS countStated, p.countDistinct AS countDistinct
1540
+ ORDER BY id, uri`),n=new Map,r=new Map,i=new Map,a=new Map;for(let e of t){let t=String(e.id),o=String(e.uri),s=wq(e.startDay),c=n.get(t)??{id:t,scope:Cq(e.scope)===`CONTAINER`?`CONTAINER`:`RUN`,key:Cq(e.key)??t,members:[],owned:!1,startDay:null,runLength:wq(e.runLength)};c.members.push(o),c.owned=c.owned||e.owned===!0,s!==null&&(c.startDay=c.startDay===null?s:Math.min(c.startDay,s)),n.set(t,c),r.set(o,t),i.set(o,{folding:e.folding===!0,count:wq(e.countDistinct)??wq(e.countStated)}),s!==null&&a.set(o,s)}return{clusters:n,clusterOf:e=>r.get(e),folding:i,startDayOf:a}},zq=async e=>(await e.query(`MATCH (a:Media)-[l:LINK]->(b:Media)
1541
+ WHERE l.status = 'active' AND l.kind IN ['PART_OF', 'INCLUDES']
1542
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.kind AS kind, l.reason AS reason, l.key AS linkKey
1543
+ ORDER BY fromUri, toUri, kind, reason`)).map(e=>({fromUri:String(e.fromUri),toUri:String(e.toUri),kind:String(e.kind)===`INCLUDES`?`INCLUDES`:`PART_OF`,reason:Cq(e.reason)??``,key:Cq(e.linkKey)??``})),Bq=async e=>{let t=await e.query(`MATCH (m:Media)-[h:HAS_EPISODE]->(e:Episode)
1544
+ MATCH (p:EpisodeProfile)-[:PROFILE_OF]->(e)
1545
+ WHERE h.claimer = m.origin AND p.day IS NOT NULL
1546
+ RETURN m.uri AS uri, p.day AS day ORDER BY uri`),n=new Map;for(let e of t){let t=String(e.uri),r=wq(e.day);if(r===null)continue;let i=n.get(t);n.set(t,i?{first:Math.min(i.first,r),last:Math.max(i.last,r)}:{first:r,last:r})}return n},Vq=e=>{if(typeof e==`object`&&e&&!Array.isArray(e))return e;if(typeof e!=`string`||!e)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}},Hq=async e=>{let t=await e.query(`MATCH (a:Media)-[l:LINK]->(b:Media)
1547
+ WHERE l.status = 'active' AND l.kind = 'SAME_AS'
1548
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.key AS linkKey, l.evidence AS evidence, l.supports AS supports
1549
+ ORDER BY fromUri, toUri`);if(!t.length)return[];let n=new Map;for(let t of await e.query(`MATCH (a:Media)-[c:CLAIMS]->(b:Media) RETURN c.key AS claimKey, c.seq AS seq`))n.set(String(t.claimKey),wq(t.seq)??0);return t.map(e=>{let t=Array.isArray(e.supports)?e.supports.map(String):[];return{fromUri:String(e.fromUri),toUri:String(e.toUri),key:Cq(e.linkKey)??``,className:pq({kind:`SAME_AS`,fromUri:String(e.fromUri),toUri:String(e.toUri),reason:``,confidence:1,evidence:Vq(e.evidence),supports:t}),seq:Math.max(0,...t.map(e=>n.get(e)??0))}})},Uq=async e=>(await e.query(`MATCH (a:Media)-[l:LINK]->(b:Media)
1550
+ WHERE l.status = 'refused' AND l.kind = 'SAME_AS' AND l.reason = 'contained'
1551
+ RETURN a.uri AS fromUri, b.uri AS toUri ORDER BY fromUri, toUri`)).map(e=>({fromUri:String(e.fromUri),toUri:String(e.toUri)})),Wq=e=>({kind:`PART_OF`,fromUri:e.fromUri,toUri:e.toUri,...e.status?{status:e.status}:{},reason:e.reason,confidence:1,evidence:e.evidence,supports:e.supports}),Gq={id:`plugin:containment`,consumes:{nodes:[`Cluster`,`Media`,`Episode`,`MediaProfile`,`EpisodeProfile`],edges:[`MEMBER_OF`,`LINK`,`HAS_EPISODE`],kinds:[`PART_OF`,`INCLUDES`]},produces:{nodes:[],edges:[`ATTACHED_TO`,`LINK`],kinds:[`PART_OF`]},after:[`plugin:aggregate`],version:1,run:async e=>{let[{clusters:t,clusterOf:n,folding:r,startDayOf:i},a,o,s,c]=await Promise.all([Rq(e),zq(e),Bq(e),Hq(e),Uq(e)]),l=kq({links:a,clusterOf:n,clusters:t}).map(e=>({from:e.from,to:e.to,via:e.via,supports:e.supports})),u=new Map;for(let e of a){if(e.kind!==`PART_OF`)continue;let a=n(e.fromUri),s=a?t.get(a):void 0;if(!s||s.scope!==`RUN`||s.runLength===null)continue;let c=i.get(e.fromUri);if(c===void 0)continue;let l=r.get(e.toUri);if(!l?.folding||l.count===null||l.count<=s.runLength)continue;let d=o.get(e.toUri);if(!d||d.first>c||c>d.last)continue;let f={runCluster:s.id,runUri:e.fromUri,seasonUri:e.toUri,first:d.first,last:d.last,startDay:c,theirCount:l.count,runLength:s.runLength};u.set(s.id,[...u.get(s.id)??[],f])}let d=[];for(let[t,n]of[...u].sort(([e],[t])=>xq(e,t))){let r=jq(n);if(!r.ok){e.log({level:`warn`,rule:`span-ambiguous`,detail:`${t} is covered by ${Sq(n.map(e=>e.seasonUri)).join(`, `)}, so no season holds it`,uris:Sq(n.map(e=>e.seasonUri))});for(let e of r.candidates)d.push(Wq({fromUri:e.runUri,toUri:e.seasonUri,reason:`span`,status:`refused`,evidence:{first:e.first,last:e.last,startDay:e.startDay,theirCount:e.theirCount,runLength:e.runLength,candidates:Sq(n.map(e=>e.seasonUri))},supports:[]}));continue}for(let e of r.candidates)d.push(Wq({fromUri:e.runUri,toUri:e.seasonUri,reason:`span`,evidence:{first:e.first,last:e.last,startDay:e.startDay,theirCount:e.theirCount,runLength:e.runLength},supports:[]}))}let f=Lq({links:a,clusters:t,clusterOf:n,sameAs:s,containedRefusals:c});for(let e of f)d.push(Wq({fromUri:e.part,toUri:e.member,reason:`inside`,evidence:{whole:e.whole,retracts:e.retracts,class:e.className,seq:e.seq},supports:e.retracts?[e.retracts]:[]}));return f.length&&e.log({level:`warn`,rule:`part-of-inside`,detail:`${f.length} containment edge(s) sat inside one cluster; the weaker SAME_AS loses (3.5), weakest first: ${f[0].part} to ${f[0].member}`,uris:Sq(f.flatMap(e=>[e.part,e.member]))}),{scope:{full:!0},nodes:[],edges:[{table:`ATTACHED_TO`,rows:l}],links:d,episodeLinks:[]}}},Kq=e=>typeof e==`string`&&e?e:null,qq=e=>e==null?null:Number.isFinite(Number(e))?Number(e):null,Jq=e=>{if(e==null)return{};if(typeof e==`object`&&!Array.isArray(e))return e;if(typeof e!=`string`||!e)return{};try{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}},Yq=e=>{let t=Jq(e),n={};for(let[e,r]of Object.entries(t)){let t=qq(r);t!==null&&(n[e]=t)}return n},Xq=(e,t)=>e<t?-1:+(e>t),Zq=e=>[...new Set(e)].sort(Xq),Qq=async e=>{let t=await e.query(`MATCH (p:MediaProfile)-[:PROFILE_OF]->(m:Media)
1552
+ RETURN m.uri AS uri, m.origin AS origin, m.id AS id, m.owned AS owned, m.score AS score,
1553
+ m.raw AS raw, m.fieldSeq AS fieldSeq, p.scope AS scope, p.countKind AS countKind,
1554
+ p.countStated AS countStated, p.countDistinct AS countDistinct, p.startDay AS startDay
1555
+ ORDER BY uri`),n=[];for(let e of t){let t=Kq(e.scope);t!==`RUN`&&t!==`CONTAINER`||n.push({uri:String(e.uri),origin:String(e.origin??``),id:String(e.id??``),owned:e.owned===!0,score:qq(e.score),raw:Jq(e.raw),fieldSeq:Yq(e.fieldSeq),scope:t,countKind:Kq(e.countKind)??`none`,countStated:qq(e.countStated),countDistinct:qq(e.countDistinct),startDay:qq(e.startDay)})}return n},$q=async e=>(await e.query(`MATCH (a:Media)-[l:LINK]->(b:Media)
1556
+ WHERE l.status = 'active' AND l.kind IN ['PART_OF', 'INCLUDES']
1557
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.kind AS kind, l.reason AS reason, l.by AS by,
1558
+ l.key AS linkKey
1559
+ ORDER BY fromUri, toUri, kind`)).map(e=>({fromUri:String(e.fromUri),toUri:String(e.toUri),kind:String(e.kind)===`INCLUDES`?`INCLUDES`:`PART_OF`,reason:Kq(e.reason)??``,by:Kq(e.by)??``,key:Kq(e.linkKey)??``})),eJ=e=>{let t=Jq(e.raw);return{mediaUri:String(e.mediaUri),uri:String(e.uri),origin:String(e.origin??``),id:String(e.id??``),number:qq(e.episodeNumber),seasonNumber:qq(e.seasonNumber),numberSpace:Kq(e.numberSpace)??`season`,score:qq(t.score),raw:t,fieldSeq:Yq(e.fieldSeq),hasEpisodeKey:String(e.hasEpisodeKey??``)}},tJ=async e=>(await e.query(`MATCH (m:Media)-[h:HAS_EPISODE]->(e:Episode)
1560
+ WHERE h.claimer = m.origin
1561
+ MATCH (p:EpisodeProfile)-[:PROFILE_OF]->(e)
1562
+ RETURN m.uri AS mediaUri, e.uri AS uri, e.origin AS origin, e.id AS id,
1563
+ e.episodeNumber AS episodeNumber, e.seasonNumber AS seasonNumber, e.raw AS raw,
1564
+ e.fieldSeq AS fieldSeq, p.numberSpace AS numberSpace, h.key AS hasEpisodeKey
1565
+ ORDER BY mediaUri, uri`)).map(eJ),nJ=async e=>(await e.query(`MATCH (a:Episode)-[l:EPISODE_LINK]->(b:Episode)
1566
+ WHERE l.status = 'active'
1567
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.toNumber AS toNumber, l.key AS linkKey
1568
+ ORDER BY fromUri, toUri`)).map(e=>({fromUri:String(e.fromUri),toUri:String(e.toUri),toNumber:qq(e.toNumber),key:Kq(e.linkKey)??``})),rJ=async e=>(await e.query(`MATCH (a:Episode)-[l:EPISODE_LINK]->(b:Episode)
1569
+ WHERE l.status = 'active' AND l.by = $by
1570
+ MATCH (m:Media)-[h:HAS_EPISODE]->(a)
1571
+ MATCH (p:EpisodeProfile)-[:PROFILE_OF]->(a)
1572
+ RETURN m.uri AS mediaUri, a.uri AS uri, a.origin AS origin, a.id AS id,
1573
+ a.episodeNumber AS episodeNumber, a.seasonNumber AS seasonNumber, a.raw AS raw,
1574
+ a.fieldSeq AS fieldSeq, p.numberSpace AS numberSpace, h.key AS hasEpisodeKey,
1575
+ b.uri AS toUri, l.toNumber AS toNumber, l.key AS linkKey
1576
+ ORDER BY uri, toUri, mediaUri`,{by:`plugin:range`})).map(e=>({row:eJ(e),toUri:String(e.toUri),toNumber:qq(e.toNumber),linkKey:Kq(e.linkKey)??``})),iJ=async e=>(await e.query(`MATCH (a:Media)-[r:RELATED]->(b:Media)
1577
+ RETURN a.uri AS fromUri, b.uri AS toUri, r.relation AS relation, r.format AS format,
1578
+ r.claimer AS claimer, r.node AS node
1579
+ ORDER BY fromUri, toUri, relation`)).map(e=>({fromUri:String(e.fromUri),toUri:String(e.toUri),relation:Kq(e.relation)??`UNKNOWN`,format:Kq(e.format),claimer:Kq(e.claimer)??``,node:Jq(e.node)})),aJ=async(e,t)=>{let n=new Map;if(!t.length)return n;let r=await e.query(`UNWIND $uris AS u
1580
+ MATCH (a:Media)-[c:CLAIMS]->(b:Media {uri: u})
1581
+ RETURN u AS uri, a.uri AS claimant, a.score AS score, c.node AS node
1582
+ ORDER BY uri, claimant`,{uris:t}),i=new Map;for(let e of r){let t=String(e.uri),r=Kq(Jq(e.node).url);if(!r)continue;let a=qq(e.score)??-1;n.has(t)&&(i.get(t)??-1)>=a||(n.set(t,r),i.set(t,a))}return n},oJ=()=>({clusters:new Map,memberOf:new Map,aliases:new Set}),sJ=async e=>{let t=oJ(),n=e.previous.nodes.Cluster,r=e.previous.edges.MEMBER_OF;if(n?.size){for(let e of n.values()){t.clusters.set(String(e.id),{id:String(e.id),key:String(e.key??``),published:e.published??[],aliases:e.aliases??[]});for(let n of e.aliases??[])t.aliases.add(n)}for(let e of r?.values()??[])t.memberOf.set(String(e.from),String(e.to));return t}let i=await e.query(`MATCH (c:Cluster) WHERE c.by = $by
1583
+ RETURN c.id AS id, c.key AS key, c.published AS published, c.aliases AS aliases ORDER BY id`,{by:e.id});for(let e of i){let n=String(e.id),r=Array.isArray(e.published)?e.published.map(String):[],i=Array.isArray(e.aliases)?e.aliases.map(String):[];t.clusters.set(n,{id:n,key:String(e.key??``),published:r,aliases:i});for(let e of i)t.aliases.add(e)}let a=await e.query(`MATCH (m:Media)-[e:MEMBER_OF]->(c:Cluster) WHERE e.by = $by
1584
+ RETURN m.uri AS uri, c.id AS id ORDER BY uri`,{by:e.id});for(let e of a)t.memberOf.set(String(e.uri),String(e.id));let o=await e.query(`MATCH (a:Alias) WHERE a.by = $by RETURN a.id AS id ORDER BY id`,{by:e.id});for(let e of o)t.aliases.add(String(e.id));return t},cJ=(e,t)=>{let n=new Map;e.forEach((e,t)=>{for(let r of e.members)n.set(r,t)});let r=new Map;for(let[i,a]of[...t.clusters].sort(([e],[t])=>Xq(e,t))){let o=new Map;for(let[e,r]of t.memberOf){if(r!==i)continue;let t=n.get(e);t!==void 0&&o.set(t,(o.get(t)??0)+1)}if(!o.size)continue;let s=n.get(a.key),c=s!==void 0&&t.memberOf.get(a.key)===i?s:[...o].sort((t,n)=>n[1]-t[1]||Xq(e[t[0]].key,e[n[0]].key))[0][0];r.set(c,[...r.get(c)??[],i])}let i=new Map,a=new Set;return e.forEach((e,n)=>{let o=r.get(n)??[];if(!o.length){i.set(e.key,{id:lJ(e.key,t,a),retired:[]});return}let s=n=>e.members.filter(e=>t.memberOf.get(e)===n).length,c=[...o].sort((e,n)=>s(n)-s(e)||Xq(t.clusters.get(e)?.key??e,t.clusters.get(n)?.key??n))[0];i.set(e.key,{id:c,retired:o.filter(e=>e!==c).sort(Xq)})}),i},lJ=(e,t,n)=>{let r=`cl:${e}`,i=r;for(let e=2;t.clusters.has(i)||t.aliases.has(i)||n.has(i);e+=1)i=`${r}#${e}`;return n.add(i),i},uJ=e=>{let t=e.filter(e=>e.countKind!==`none`&&e.countStated!==null),n=t.filter(e=>e.countKind===`declared`),r=n.length?n:t.filter(e=>e.countKind===`listLength`);if(!r.length)return null;let i=eR(r.map(e=>({value:e.countStated,score:e.score})));if(!i)return null;let a=t.filter(e=>e.countStated===i.value);return{length:i.value,tier:i.tier,witnesses:a.length,from:Zq(a.map(e=>e.uri))}},dJ=e=>{let{run:t,member:n,number:r}=e;return r===null||r>=1&&r<=t.length||t.witnesses<2||e.reference.has(n.origin)||e.equals.has(n.origin)?!1:e.backingWeight>=2*(n.score??0)},fJ=()=>{let e=new Map,t=t=>{let n=t;for(;e.get(n)&&e.get(n)!==n;)n=e.get(n);let r=t;for(;e.get(r)&&e.get(r)!==r;){let t=e.get(r);e.set(r,n),r=t}return n};return{add:t=>{e.has(t)||e.set(t,t)},find:t,union:(n,r)=>{e.set(n,e.get(n)??n),e.set(r,e.get(r)??r);let i=t(n),a=t(r);i!==a&&(i<a?e.set(a,i):e.set(i,a))},keys:()=>[...e.keys()].sort(Xq)}},pJ=e=>e!==null&&Number.isInteger(e)&&e>=1,mJ=e=>{let{clusterId:t,episodes:n}=e,r=new Set(n.map(e=>e.uri)),i=fJ();for(let e of n)i.add(e.uri);for(let t of e.links)r.has(t.fromUri)&&r.has(t.toUri)&&i.union(t.fromUri,t.toUri);let a=t=>e.renumber.get(t.uri)?.number??t.number,o=new Map;for(let e of n){let t=a(e);if(!pJ(t))continue;let n=o.get(t);n?i.union(n,e.uri):o.set(t,e.uri)}let s=new Map;for(let e of[...n].sort((e,t)=>Xq(e.uri,t.uri))){let t=i.find(e.uri);s.set(t,[...s.get(t)??[],e])}let c=[];for(let[n,r]of[...s].sort(([e],[t])=>Xq(e,t))){let i=r.map(a).filter(pJ),o=i.length?Math.min(...i):null;c.push({id:o===null?`${t}#s:${n}`:`${t}#${o}`,number:o,rows:r.map(t=>{let n=e.renumber.get(t.uri);return{row:t,number:a(t),via:n?`aligned`:`member`,supports:[t.hasEpisodeKey,...n?[n.key]:[]].filter(Boolean)}})})}return c.sort((e,t)=>(e.number===null)-+(t.number===null)||(e.number??0)-(t.number??0)||Xq(e.id,t.id))},hJ=e=>{let t=new Map;for(let n of e.slots)n.number!==null&&!t.has(n.number)&&t.set(n.number,n);let n=[],r=new Set;for(let i of[...e.pairs].sort((e,t)=>Xq(e.uri,t.uri)||Xq(e.toUri,t.toUri))){let a=i.toNumber;if(!pJ(a)||e.own.has(i.uri)||e.runLength!==null&&a>e.runLength)continue;let o=t.get(a);if(!o||!o.filled.includes(i.toUri))continue;let s=`${i.uri} ${o.id}`;r.has(s)||(r.add(s),n.push({uri:i.uri,slotId:o.id,number:a,supports:i.supports}))}return n},gJ=e=>!e.length||e.some(e=>e.seasonNumber===null)?!1:new Set(e.map(e=>e.seasonNumber)).size===1,_J={id:`plugin:aggregate`,consumes:{nodes:[`Media`,`Episode`,`MediaProfile`,`EpisodeProfile`],edges:[`LINK`,`EPISODE_LINK`,`HAS_EPISODE`,`CLAIMS`,`RELATED`,`ATTACHED_TO`],kinds:[`SAME_AS`,`PART_OF`,`INCLUDES`]},produces:{nodes:[`Cluster`,`Alias`,`Slot`],edges:[`MEMBER_OF`,`SLOT_OF`,`FILLS`]},after:[`plugin:direct`],version:1,run:async e=>{let t=globalThis.location===void 0?``:globalThis.location.origin,[n,r,i,a,o,s,c,l]=await Promise.all([Qq(e),$q(e),tJ(e),nJ(e),rJ(e),iJ(e),RK(e.query),sJ(e)]),u=new Map(n.map(e=>[e.uri,e])),d=new Map;for(let e of n){let t=c.keyOf(e.uri);d.set(t,[...d.get(t)??[],e])}let f=[...d].map(([e,t])=>({key:e,members:t.map(e=>e.uri).sort(Xq)})).sort((e,t)=>Xq(e.key,t.key)),p=cJ(f,l),m=new Map,h=new Map,g=new Map;for(let e of f){let t=e.members.map(e=>u.get(e)),n=p.get(e.key).id,r=uJ(t);g.set(e.key,r);let i=t.map(e=>e.startDay).filter(e=>e!==null);m.set(n,{id:n,scope:t.every(e=>e.scope===`CONTAINER`)?`CONTAINER`:`RUN`,key:e.key,members:[...e.members],owned:t.some(e=>e.owned),startDay:i.length?Math.min(...i):null,runLength:r?.length??null});for(let t of e.members)h.set(t,n)}let _=e=>h.get(e),v=kq({links:r,clusterOf:_,clusters:m}),y=Mq({clusters:m,clusterOf:_,links:r,attachments:v}),b=await oq(e.query),x=new Map;for(let e of b)for(let t of e.uris)x.set(t,[...x.get(t)??[],e]);let S=new Set;for(let e of r)u.get(e.toUri)?.owned||S.add(e.toUri);let C=await aJ(e,[...S].sort(Xq)),w=new Map;for(let e of i)w.set(e.mediaUri,[...w.get(e.mediaUri)??[],e]);let ee=new Map;for(let e of a)e.toNumber!==null&&ee.set(e.fromUri,{toUri:e.toUri,number:e.toNumber,key:e.key});let te=new Map;for(let e of o)te.set(e.toUri,[...te.get(e.toUri)??[],e]);let ne=[],re=[],ie=[],ae=[],T=[],E=[];for(let e of f){let n=OH(e.members.map(e=>u.get(e))),i=p.get(e.key),o=i.id,c=m.get(o),d=c.scope,f=l.clusters.get(o),h=Zq([...f?.published??[],...i.retired.flatMap(e=>l.clusters.get(e)?.published??[]),...n.map(e=>e.uri).filter(WS)]),_=Zq([...f?.aliases??[],...i.retired,...i.retired.flatMap(e=>l.clusters.get(e)?.aliases??[])]),b=`ag:(${h.join(`,`)})`,S=g.get(e.key)??null,oe={runLength:S?.length??null,runLengthTier:S?.tier??null,runLengthWitnesses:S?.witnesses??0,runLengthFrom:S?.from??[]},se=Pq(c,y),ce=d===`CONTAINER`?Aq({container:o,attachments:v,clusters:m}):null,le=n.flatMap(e=>w.get(e.uri)??[]),ue=d===`RUN`||ce===null&&gJ(le),de=new Set(S?n.filter(e=>e.countStated===S.length).map(e=>e.origin):[]),fe=new Set(S?n.filter(e=>(e.score??0)>=S.tier).map(e=>e.origin):[]),pe=S?n.filter(e=>e.countStated===S.length).reduce((e,t)=>e+(t.score??0),0):0,D=new Map;for(let e of le){let t=ee.get(e.uri);t&&le.some(e=>e.uri===t.toUri&&de.has(e.origin))&&D.set(e.uri,{number:t.number,key:t.key})}let me=(e,t)=>{let n=u.get(e.mediaUri);return n&&e.numberSpace===`position`&&n.countDistinct!==null&&n.countStated!==null&&n.countDistinct!==n.countStated?!1:S?!dJ({run:S,reference:de,equals:fe,backingWeight:pe,member:{origin:n?.origin??e.origin,score:n?.score??e.score},number:t}):!0},he=ue?le.filter(e=>u.has(e.mediaUri)&&me(e,D.get(e.uri)?.number??e.number)):[],ge=mJ({clusterId:o,episodes:he,renumber:D,links:a}),_e=new Set(le.map(e=>e.uri)),ve=he.flatMap(e=>te.get(e.uri)??[]).filter(e=>!_e.has(e.row.uri)&&me(e.row,e.toNumber)),ye=new Map(ve.map(e=>[e.row.uri,e.row])),be=hJ({slots:ge.map(e=>({id:e.id,number:e.number,filled:e.rows.map(e=>e.row.uri)})),runLength:S?.length??null,own:_e,pairs:ve.map(e=>({uri:e.row.uri,toUri:e.toUri,toNumber:e.toNumber,supports:[e.row.hasEpisodeKey,e.linkKey].filter(Boolean)}))}),O=new Map(ge.map(e=>[e.id,e]));for(let e of be)O.get(e.slotId)?.rows.push({row:ye.get(e.uri),number:e.number,via:`aligned`,supports:e.supports});let xe=[];for(let e of ge){let t=e.rows.map(e=>({uri:e.row.uri,origin:e.row.origin,id:e.row.id,score:e.row.score,raw:e.row.raw,fieldSeq:e.row.fieldSeq,via:e.via})),n=GH({slot:{id:e.id,number:e.number},clusterUri:b,rows:t});xe.push(n),ae.push({id:e.id,clusterId:o,number:e.number,episode:n}),T.push({from:e.id,to:o});for(let t of e.rows)E.push({from:t.row.uri,to:e.id,via:t.via,number:t.number,supports:t.supports})}let Se=new Set(e.members),Ce=r.filter(e=>Se.has(e.fromUri)&&!Se.has(e.toUri)).map(e=>{let t=u.get(e.toUri);return{uri:e.toUri,origin:t?.origin??e.toUri.slice(0,e.toUri.indexOf(`:`)),id:t?.id??e.toUri.slice(e.toUri.indexOf(`:`)+1),url:(t?.owned?Kq(t.raw.url):null)??C.get(e.toUri)??null,relation:e.kind,via:e.reason,by:e.by}}),we=Zq(e.members.flatMap(e=>(x.get(e)??[]).map(e=>`${e.rule}\u0000${e.detail}`))).map(e=>({rule:e.slice(0,e.indexOf(`\0`)),detail:e.slice(e.indexOf(`\0`)+1)})),Te=HH({cluster:{id:o,aggUri:b,scope:d,...oe,anomalies:we},members:n,related:Ce,relations:s.filter(e=>Se.has(e.fromUri)),locationOrigin:t}),Ee=n.some(e=>e.owned);ne.push({id:o,scope:d,key:e.key,published:h,aggUri:b,aliases:_,hidden:se.hidden,hiddenBy:se.hiddenBy,kind:se.kind,...oe,preferredRun:ce,card:Ee?UH(Te,e.members):null,media:Te,episodes:xe,anomalies:we,anomalyCount:we.length});for(let e of _)re.push({id:e,clusterId:o});for(let e of n)ie.push({from:e.uri,to:o,via:n.length>1?`same-as`:`self`})}return{scope:{full:!0},nodes:[{table:`Cluster`,rows:ne},{table:`Alias`,rows:re},{table:`Slot`,rows:ae}],edges:[{table:`MEMBER_OF`,rows:ie},{table:`SLOT_OF`,rows:T},{table:`FILLS`,rows:E}],links:[],episodeLinks:[]}}},vJ=e=>typeof e==`string`&&e?e:null,yJ=async(e,t)=>{let n=`RETURN a.uri AS fromUri, b.uri AS toUri, a.origin AS fromOrigin, b.origin AS toOrigin,
1585
+ c.kind AS kind, c.claimer AS claimer, c.provenance AS provenance, c.key AS claimKey`,r=`ORDER BY fromUri, toUri, kind, claimer`,i=[],a=new Map;if(t===void 0)i=await e.query(`MATCH (a:Media)-[c:CLAIMS]->(b:Media)
1586
+ MATCH (pa:MediaProfile)-[:PROFILE_OF]->(a), (pb:MediaProfile)-[:PROFILE_OF]->(b)
1587
+ ${n}, pa.scope AS fromScope, pb.scope AS toScope,
1588
+ pa.idParent AS fromParent, pb.idParent AS toParent
1589
+ ${r}`);else if(t.length){let o=new Map;for(let i of[`(a:Media {uri: u})-[c:CLAIMS]->(b:Media)`,`(a:Media)-[c:CLAIMS]->(b:Media {uri: u})`]){let a=await e.query(`UNWIND $uris AS u MATCH ${i} ${n} ${r}`,{uris:t});for(let e of a)o.set(String(e.claimKey),e)}i=[...o.values()].sort((e,t)=>[`fromUri`,`toUri`,`kind`,`claimer`,`claimKey`].reduce((n,r)=>n||String(e[r]).localeCompare(String(t[r])),0));let s=[...new Set(i.flatMap(e=>[String(e.fromUri),String(e.toUri)]))];if(s.length){let t=await e.query(`UNWIND $uris AS u MATCH (p:MediaProfile {uri: u})
1590
+ RETURN p.uri AS uri, p.scope AS scope, p.idParent AS idParent`,{uris:s});for(let e of t)a.set(e.uri,{scope:e.scope,idParent:e.idParent})}i=i.filter(e=>a.has(String(e.fromUri))&&a.has(String(e.toUri)))}return i.map(e=>{let t=a.get(String(e.fromUri)),n=a.get(String(e.toUri));return{fromUri:String(e.fromUri),toUri:String(e.toUri),fromOrigin:String(e.fromOrigin),toOrigin:String(e.toOrigin),kind:String(e.kind),claimer:String(e.claimer),provenance:String(e.provenance),claimKey:String(e.claimKey),fromScope:vJ(t?t.scope:e.fromScope),toScope:vJ(n?n.scope:e.toScope),fromParent:vJ(t?t.idParent:e.fromParent),toParent:vJ(n?n.idParent:e.toParent)}})},bJ=async e=>{if(e.delta.full)return;let t=[...new Set([...e.delta.media,...await vK(e,e.delta.claims)])],[n]=await e.query(`MATCH (m:Media) RETURN count(m) AS total`);return t.length*4>=Number(n?.total??0)?void 0:t},xJ=(e,t,n,r,i,a={})=>({kind:t,fromUri:n,toUri:r,...a.status?{status:a.status}:{},reason:i,confidence:1,evidence:a.evidence??{claimer:e.claimer,provenance:e.provenance},supports:[e.claimKey]}),SJ=e=>{let{fromUri:t,toUri:n,fromOrigin:r,toOrigin:i,kind:a,fromScope:o,toScope:s,fromParent:c,toParent:l}=e;if(o===null||s===null||e.provenance===`address`)return[];if(a===`INCLUDES`)return r===i&&l===t?[xJ(e,`PART_OF`,n,t,`asserted`,{evidence:{claimer:e.claimer,provenance:e.provenance,claimed:`INCLUDES`}})]:[xJ(e,`INCLUDES`,t,n,`foreign-includes`,{status:`refused`})];if(r===i){if(n===c)return[xJ(e,`PART_OF`,t,n,`prefix`)];if(t===l)return[xJ(e,`PART_OF`,n,t,`prefix`)];let r=xJ(e,`PART_OF`,t,n,`disagreeing-ids`,{evidence:{claimer:e.claimer,provenance:e.provenance,theirs:n,ours:t}});return a===`PART_OF`?[r]:[xJ(e,`SAME_AS`,t,n,`disagreeing-ids`,{status:`refused`}),r]}if(a===`PART_OF`){if(o===`CONTAINER`&&s===`RUN`)return[xJ(e,`PART_OF`,t,n,`inverted`,{status:`refused`})];let r=e.provenance===`ask`?`containing`:`asserted`;return[xJ(e,`PART_OF`,t,n,r)]}if(o!==s){let[r,i]=o===`RUN`?[t,n]:[n,t];return[xJ(e,`PART_OF`,r,i,`cross-scope`,{evidence:{claimer:e.claimer,provenance:e.provenance,theirs:`CONTAINER`,ours:`RUN`}})]}return[xJ(e,`SAME_AS`,t,n,`asserted`)]},CJ={id:`plugin:direct`,consumes:{nodes:[`MediaProfile`],edges:[`CLAIMS`,`LINK`]},produces:{nodes:[],edges:[`LINK`],kinds:[`SAME_AS`,`PART_OF`]},after:[`plugin:profile`],version:1,run:async e=>{let t=await bJ(e),n=await yJ(e,t),r=[];for(let e of n)r.push(...SJ(e));return{scope:t===void 0?{full:!0}:{full:!1,uris:t,clusters:[],pairs:[]},nodes:[],edges:[],links:r,episodeLinks:[]}}},wJ=(e,t)=>e<t?-1:+(e>t),TJ=(e,t)=>wJ(e.uri,t.uri),EJ=(e,t)=>{let n=new Map;for(let t of[...e].sort(TJ)){if(t.day===null||t.number===null)continue;let e=n.get(t.day)??new Map;e.has(t.number)||e.set(t.number,t),n.set(t.day,e)}if(!n.size)return{pairs:[],ambiguous:0};let r=[],i=0;for(let e of[...t].sort(TJ)){if(e.day===null||e.number===null)continue;let t=new Map;for(let r of[e.day,e.day-1,e.day+1])for(let[e,i]of n.get(r)??[])t.has(e)||t.set(e,i);if(!t.size)continue;if(t.size>1){i+=1;continue}let[a]=[...t.values()];r.push({from:e,to:a,fromNumber:e.number,toNumber:a.number,evidence:{day:e.day,slack:e.day-a.day}})}return{pairs:r,ambiguous:i}},DJ=e=>{let{runLength:t,episodes:n,pairs:r}=e;if(!r.length)return null;let i=r[0].toNumber-r[0].fromNumber;if(r.some(e=>e.toNumber-e.fromNumber!==i))return null;let a=n.map(e=>e.number).filter(e=>e!==null);return Math.min(...a)!==1||Math.max(...a)>t||a.every(e=>e+i>=1&&e+i<=t)?null:i},OJ=e=>{let{reference:t,theirs:n,pairs:r}=e;if(!r.length)return[];let i=kJ(t,MJ),a=kJ(n,MJ),o=[];for(let e of[...n].sort(TJ)){if(e.number===null)continue;let t=new Map;for(let n of MJ(e)){if(a.get(n)!==e)continue;let r=i.get(n);!r||r.number===null||t.has(r.uri)||t.set(r.uri,{target:r,key:n})}if(t.size!==1)continue;let[n]=[...t.values()],r=n.target;o.push({from:e,to:r,fromNumber:e.number,toNumber:r.number,evidence:{gap:n.key}})}let s=(e,t)=>(e.fromNumber-t.fromNumber)*(e.toNumber-t.toNumber)<=0,c=o.filter(e=>r.every(t=>!s(e,t)));return c.some((e,t)=>c.some((n,r)=>r>t&&s(e,n)))?[]:c},kJ=(e,t=AJ)=>{let n=new Map;for(let r of[...e].sort(TJ))for(let e of t(r))n.has(e)?n.set(e,null):n.set(e,r);return n},AJ=e=>[...new Set(e.keys.map(mT).filter(Boolean))].sort(wJ),jJ=(e,t)=>{let n=kJ(e),r=kJ(t),i=t.filter(e=>AJ(e).length).length,a=[];for(let e of[...t].sort(TJ)){if(e.number===null)continue;let t=new Map;for(let i of AJ(e)){if(r.get(i)!==e)continue;let a=n.get(i);!a||a.number===null||t.has(a.uri)||t.set(a.uri,{target:a,key:i})}if(t.size!==1)continue;let[i]=[...t.values()];a.push({from:e,to:i.target,fromNumber:e.number,toNumber:i.target.number,evidence:{key:i.key}})}return{pairs:a,titled:i,coverage:i?a.length/i:0}},MJ=e=>AJ(e).filter(e=>!UD(e)),NJ=(e,t,n)=>({from:e,to:t.rows[0],fromNumber:e.number,toNumber:t.number,evidence:n}),PJ=e=>{let t=[],n=[];e.forEach((r,i)=>{let a=0,o=t.length;for(;a<o;){let n=a+o>>1;e[t[n]].toIndex<r.toIndex?a=n+1:o=n}n[i]=a>0?t[a-1]:-1,t[a]=i});let r=[];for(let i=t.length?t[t.length-1]:-1;i>=0;i=n[i])r.push(e[i]);return r.reverse()},FJ=(e,t)=>{let n=new Set(e.split(` `).filter(Boolean)),r=new Set(t.split(` `).filter(Boolean));if(!n.size||!r.size)return 0;let i=0;for(let e of n)r.has(e)&&(i+=1);return 2*i/(n.size+r.size)},IJ=e=>e.anchors.length>e.scored+e.synopsis?2:3,LJ=(e,t)=>{let n={score:0,key:``,onto:``,row:null};for(let r of e)for(let e of t)for(let t of e.keys){let i=FJ(r,t);i>n.score&&(n={score:i,key:r,onto:t,row:e.row})}return n},RJ=(e,t)=>t.every(t=>e.fromIndex<t.fromIndex&&e.toIndex<t.toIndex||e.fromIndex>t.fromIndex&&e.toIndex>t.toIndex),zJ=e=>{let{ordered:t,canonical:n,matches:r,anchors:i}=e,a=new Set(r.map(e=>e.from.uri)),o=new Set(r.map(e=>e.toIndex)),s=n.map(e=>e.rows.map(e=>({row:e,keys:MJ(e)}))),c=[];t.forEach((e,t)=>{if(a.has(e.uri))return;let n=MJ(e),r={index:-1,score:0,key:``,onto:``,row:null},l=0;if(s.forEach((e,t)=>{let i=LJ(n,e);i.score>r.score?(l=r.score,r={index:t,score:i.score,key:i.key,onto:i.onto,row:i.row}):i.score>l&&(l=i.score)}),r.score<.6||!r.row||r.score-l<.15||o.has(r.index))return;let u={from:e,to:r.row,fromIndex:t,toIndex:r.index,key:r.key,scored:{onto:r.onto,score:Math.round(r.score*1e3)/1e3}};RJ(u,i)&&c.push(u)});let l=new Map;for(let e of c)l.set(e.toIndex,(l.get(e.toIndex)??0)+1);return c.filter(e=>l.get(e.toIndex)===1)},BJ=e=>[...new Set(e.synopsis.map(aK).filter(Boolean))].sort(wJ),VJ=(e,t={})=>{let n=t.floor??3,r=t.gap??3,i=e.filter(e=>e.to.number!==null&&e.from.number!==null);if(i.length<n)return null;let a=e=>e.to.number-e.from.number,o=new Map;for(let e of i)o.set(a(e),(o.get(a(e))??0)+1);let s=[...o.entries()].sort((e,t)=>t[1]-e[1]||e[0]-t[0]),[c,l]=s[0];return l<n||l*2<=i.length||l-(s[1]?.[1]??0)<r?null:{offset:c,anchors:i.filter(e=>a(e)===c)}},HJ=e=>{let{ordered:t,canonical:n,taken:r,anchors:i}=e,a=e.floor??.2,o=e.margin??.05,s=new Set(r.map(e=>e.from.uri)),c=new Set(r.map(e=>e.toIndex)),l=n.map(e=>e.rows.map(e=>({row:e,keys:BJ(e)}))),u={proposed:[],anchors:[],consensus:null};if(l.every(e=>e.every(e=>!e.keys.length)))return u;let d=[];t.forEach((e,t)=>{if(s.has(e.uri))return;let n=BJ(e);if(!n.length)return;let r={index:-1,score:0,key:``,row:null},u=0;if(l.forEach((e,t)=>{let i=LJ(n,e);i.score>r.score?(u=r.score,r={index:t,score:i.score,key:i.key,row:i.row}):i.score>u&&(u=i.score)}),r.score<a||!r.row||r.score-u<o||c.has(r.index))return;let f={from:e,to:r.row,fromIndex:t,toIndex:r.index,key:r.key,synopsis:{score:Math.round(r.score*1e3)/1e3,consensus:0}};RJ(f,i)&&d.push(f)});let f=VJ(d,{gap:e.gap});if(!f)return{...u,proposed:d};let p=new Map;for(let e of f.anchors)p.set(e.toIndex,(p.get(e.toIndex)??0)+1);return{proposed:d,anchors:f.anchors.filter(e=>p.get(e.toIndex)===1).map(e=>({...e,synopsis:{...e.synopsis,consensus:f.offset}})),consensus:f.offset}},UJ=(e,t)=>{let n=[...t].filter(e=>e.number!==null).sort((e,t)=>e.number-t.number||wJ(e.uri,t.uri)),r=new Map;for(let t of[...e].sort(TJ))t.number!==null&&r.set(t.number,[...r.get(t.number)??[],t]);let i=[...r.keys()].sort((e,t)=>e-t).map(e=>({number:e,rows:r.get(e)})),a=[...e].filter(e=>e.number===null).sort(TJ),o=new Map;i.forEach((e,t)=>{for(let n of e.rows)for(let e of MJ(n)){let r=o.get(e);r===void 0?o.set(e,{index:t,row:n}):r&&r.index!==t&&o.set(e,null)}});let s=new Map;for(let e of n)for(let t of MJ(e))s.has(t)?s.set(t,null):s.set(t,e);let c=[];n.forEach((e,t)=>{let n=new Map;for(let t of MJ(e)){if(s.get(t)!==e)continue;let r=o.get(t);r&&(n.has(r.index)||n.set(r.index,{row:r.row,key:t}))}if(n.size!==1)return;let r=[...n.entries()][0];c.push({from:e,to:r[1].row,fromIndex:t,toIndex:r[0],key:r[1].key})});let l=new Map;for(let e of c)l.set(e.toIndex,(l.get(e.toIndex)??0)+1);let u=c.filter(e=>l.get(e.toIndex)===1),d=PJ(u),f={theirs:n,canonical:i,specials:a,matches:u.length};if(d.length>=2)return{...f,anchors:d,scored:0,synopsis:0,consensus:null};let p=zJ({ordered:n,canonical:i,matches:u,anchors:d}),m=HJ({ordered:n,canonical:i,taken:[...u,...p],anchors:d}),h=[...d,...p,...m.anchors].sort((e,t)=>e.fromIndex-t.fromIndex),g=PJ(h);return{...f,anchors:g,scored:g.filter(e=>e.scored).length,synopsis:g.filter(e=>e.synopsis).length,consensus:m.consensus}},WJ=e=>{let{anchors:t,theirs:n,canonical:r}=e;if(t.length<2)return{pairs:[],unequal:0};let i=[],a=0;for(let e=1;e<t.length;e+=1){let o=t[e-1],s=t[e],c=n.slice(o.fromIndex+1,s.fromIndex),l=r.slice(o.toIndex+1,s.toIndex);if(!c.length&&!l.length)continue;if(c.length!==l.length){a+=1;continue}let u=[o.from.uri,s.from.uri];c.forEach((e,t)=>i.push(NJ(e,l[t],{between:u})))}return{pairs:i,unequal:a}},GJ=e=>MJ(e).map(e=>new Set(e.split(` `).filter(Boolean))),KJ=(e,t)=>GJ(e).some(e=>GJ(t).some(t=>{let[n,r]=e.size<=t.size?[e,t]:[t,e];return n.size<2?!1:[...n].every(e=>r.has(e))})),qJ=e=>e.day??2**53-1,JJ=(e,t)=>{let n=e.map(e=>({row:e,matched:t.filter(t=>KJ(e,t))})),r=new Map;for(let e of n)for(let t of e.matched)r.set(t.uri,(r.get(t.uri)??0)+1);let i=[],a=!1;for(let e of n){let t=e.matched.filter(e=>r.get(e.uri)===1);if(t.length!==e.matched.length&&(a=!0),!t.length)continue;let n=[...t].sort((e,t)=>qJ(e)-qJ(t)||wJ(e.uri,t.uri));if(n.length>1&&qJ(n[0])===qJ(n[1])){a=!0;continue}i.push({from:e.row,special:n[0]})}return{located:i,ambiguous:a}},YJ=e=>{let{alignment:t,unequal:n}=e,{anchors:r,theirs:i,canonical:a,specials:o}=t,s={pairs:[],located:[],closed:!1};if(r.length<2||n)return s;let c=i.length-a.length;if(c<1)return s;let l=r[0],u=r[r.length-1],d=[{rows:i.slice(0,l.fromIndex),slots:a.slice(0,l.toIndex)},{rows:i.slice(u.fromIndex+1),slots:a.slice(u.toIndex+1)}],f=[],p=[];for(let e of d){let t=e.rows.length-e.slots.length;if(t<0)return s;let n=new Set(f.map(e=>e.special.uri)),r=JJ(e.rows,o.filter(e=>!n.has(e.uri)));if(r.ambiguous||r.located.length!==t)return s;f.push(...r.located);let i=new Set(r.located.map(e=>e.from.uri));e.rows.filter(e=>!i.has(e.uri)).forEach((t,n)=>p.push({row:t,slot:e.slots[n]}))}if(f.length!==c)return s;let m=f.map(e=>e.special.uri).sort(wJ);return{pairs:p.map(e=>NJ(e.row,e.slot,{closed:m})),located:f,closed:!0}},XJ=(e,t)=>{let n=UJ(e,t),r=n.anchors.length<IJ(n)?[]:n.anchors.map(e=>({from:e.from,to:e.to,fromNumber:e.from.number,toNumber:e.to.number,evidence:e.synopsis?{synopsisScore:e.synopsis.score,consensus:e.synopsis.consensus}:e.scored?{scored:e.key,onto:e.scored.onto,score:e.scored.score}:{anchor:e.key}})),i=WJ(n),a=YJ({alignment:n,unequal:i.unequal}),o=[...i.pairs,...a.pairs],s=r.length&&o.length?[...r,...o].sort((e,t)=>e.fromNumber-t.fromNumber||wJ(e.from.uri,t.from.uri)):[];return{alignment:n,anchored:r,forced:i.pairs,closure:a.pairs,unequal:i.unequal,located:a.located,closed:a.closed,pairs:s}},ZJ=e=>{let{runLength:t,reference:n,candidate:r}=e;if(!n.some(e=>e.number!==null))return{ok:!1,reason:`no-reference`};let i=e=>e.filter(e=>e.toNumber>=1&&e.toNumber<=t),a=EJ(n,r.episodes),o=i(a.pairs),s=o.length>=2?DJ({runLength:t,episodes:r.episodes,pairs:o}):null;if(s===null&&o.length>=2){let e=i(OJ({reference:n,theirs:r.episodes,pairs:o}));return{ok:!0,rule:`dates`,pairs:[...o,...e],coverage:1,gaps:e.length}}let c=r.retranslates?null:jJ(n,r.episodes);if(c){let e=i(c.pairs);if(e.length>=3&&c.coverage>=.6)return{ok:!0,rule:`titles`,pairs:e,coverage:c.coverage}}let l=XJ(n,r.episodes),u=i(l.pairs),d=i([...l.forced,...l.closure]).length;if((u.length>=2&&d?DJ({runLength:t,episodes:r.episodes,pairs:u}):null)===null&&u.length>=2&&d)return{ok:!0,rule:`sequence`,pairs:u,coverage:1,sequence:{anchors:l.anchored.length,scored:l.alignment.scored,synopsis:l.alignment.synopsis,consensus:l.alignment.consensus,forced:l.forced.length,closure:l.closure.length,unequal:l.unequal,closed:l.closed}};if(r.retranslates)return{ok:!1,reason:`retranslates`};if(s!==null)return{ok:!1,reason:`date-skew`};if(a.ambiguous)return{ok:!1,reason:`ambiguous-day`};if(l.unequal)return{ok:!1,reason:`unequal-gap`};let f=e=>!!(AJ(e).length||e.synopsis.length);return n.some(f)&&r.episodes.some(f)?{ok:!1,reason:l.alignment.anchors.length<IJ(l.alignment)?`no-anchors`:`no-titles`}:{ok:!1,reason:`no-dates`}},QJ=(e,t)=>`gap`in e.evidence?`dates-gap`:t,$J=(e,t)=>{if(!e.length)return null;let n=e.map(e=>e.fromNumber),r=e.map(e=>e.toNumber),i=Math.min(...n),a=Math.max(...n),o=Math.min(...r),s=Math.max(...r);return{fromStart:i,fromEnd:a,toStart:o,toEnd:s,contiguous:a-i+1===e.length&&s-o+1===e.length,aligned:e.length,total:t}},eY=e=>typeof e==`string`&&e?e:null,tY=e=>e==null?null:Number.isFinite(Number(e))?Number(e):null,nY=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],rY=e=>{if(typeof e!=`string`||!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.map(e=>e&&typeof e==`object`?e.key:void 0).filter(e=>typeof e==`string`&&!!e):[]}catch{return[]}},iY=e=>e.slice(0,e.indexOf(`:`)),aY=e=>({uri:String(e.uri),origin:eY(e.origin)??iY(String(e.uri)),number:tY(e.number),day:tY(e.day),keys:rY(e.keys),synopsis:rY(e.synopsis),hung:String(e.hung??``)}),oY=(e,t)=>{let n=(e,t)=>e.some(e=>t.includes(e));return n(e.members,t.members)||n(e.members,t.attached)||n(e.attached,t.members)},sY=(e,t)=>{let n=e.map(e=>e.number).filter(e=>e!==null);return n.length?Math.min(...n)!==1||Math.max(...n)>t:!1},cY=e=>{let{episodes:t,runLengthFrom:n,runLength:r}=e,i=new Set(n.map(iY)),a=t.filter(e=>i.has(e.origin));if(a.length)return{reference:a,origins:i};let o=new Map;for(let e of t)o.set(e.origin,[...o.get(e.origin)??[],e]);let s=new Set;for(let e of[...o.keys()].sort(wJ)){let t=o.get(e);t.some(e=>e.number!==null)&&(sY(t,r)||s.add(e))}return{reference:t.filter(e=>s.has(e.origin)),origins:s}},lY={id:`plugin:range`,consumes:{nodes:[`Cluster`,`Episode`,`EpisodeProfile`,`MediaProfile`],edges:[`MEMBER_OF`,`LINK`,`HAS_EPISODE`,`EPISODE_CLAIMS`],kinds:[`PART_OF`]},produces:{nodes:[],edges:[`LINK`,`EPISODE_LINK`],kinds:[`INCLUDES`]},after:[`plugin:aggregate`,`plugin:containment`],version:7,run:async e=>{let[t,n,r,i,a,o,s,c]=await Promise.all([e.query(`MATCH (c:Cluster)
1591
+ WHERE c.scope = 'RUN' AND c.runLength IS NOT NULL
1592
+ RETURN c.id AS id, c.runLength AS runLength, c.runLengthFrom AS runLengthFrom
1593
+ ORDER BY id`),e.query(`MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster)
1594
+ WHERE c.scope = 'RUN'
1595
+ RETURN c.id AS id, m.uri AS uri
1596
+ ORDER BY id, uri`),e.query(`MATCH (c:Cluster)<-[:MEMBER_OF]-(o:Media)-[oh:HAS_EPISODE]->(oe:Episode)<-[:PROFILE_OF]-(poe:EpisodeProfile)
1597
+ WHERE c.scope = 'RUN' AND oh.claimer = o.origin AND oe.origin = o.origin
1598
+ RETURN c.id AS runCluster, o.uri AS memberUri, oe.uri AS uri, oe.origin AS origin,
1599
+ oe.episodeNumber AS number, poe.day AS day, poe.titleKeys AS keys,
1600
+ poe.synopsisKeys AS synopsis, oh.key AS hung
1601
+ ORDER BY runCluster, uri`),e.query(`MATCH (c:Cluster)<-[:MEMBER_OF]-(r:Media)-[l:LINK]-(s:Media)<-[:PROFILE_OF]-(ps:MediaProfile)
1602
+ WHERE c.scope = 'RUN' AND l.kind = 'PART_OF' AND l.status = 'active' AND s.uri <> r.uri
1603
+ AND (l.reason IN ['count-mismatch', 'no-length', 'span', 'containing', 'contested', 'cross-scope']
1604
+ OR (l.reason = 'asserted' AND ps.folding))
1605
+ MATCH (s)-[h:HAS_EPISODE]->(se:Episode)<-[:PROFILE_OF]-(pse:EpisodeProfile)
1606
+ WHERE h.claimer = s.origin
1607
+ RETURN c.id AS runCluster, r.uri AS memberUri, s.uri AS seasonUri, l.key AS via,
1608
+ coalesce(ps.countDistinct, ps.countStated) AS theirCount, ps.retranslates AS retranslates,
1609
+ se.uri AS uri, se.origin AS origin, se.episodeNumber AS number,
1610
+ pse.day AS day, pse.titleKeys AS keys, pse.synopsisKeys AS synopsis, h.key AS hung
1611
+ ORDER BY runCluster, seasonUri, uri, memberUri, via`),e.query(`MATCH (c:Cluster)<-[:MEMBER_OF]-(m:Media)-[h:HAS_EPISODE]->(e:Episode)<-[:PROFILE_OF]-(pe:EpisodeProfile)
1612
+ WHERE c.scope = 'RUN' AND h.claimer <> m.origin
1613
+ RETURN c.id AS runCluster, m.uri AS memberUri, h.claimer AS claimer, e.uri AS uri, e.origin AS origin,
1614
+ e.episodeNumber AS number, pe.day AS day, pe.titleKeys AS keys,
1615
+ pe.synopsisKeys AS synopsis, h.key AS hung
1616
+ ORDER BY runCluster, claimer, uri, hung`),e.query(`MATCH (a:Episode)-[c:EPISODE_CLAIMS]->(b:Episode)
1617
+ WHERE c.kind = 'SAME_AS'
1618
+ RETURN a.uri AS fromUri, b.uri AS toUri, c.key AS claimKey,
1619
+ a.episodeNumber AS fromNumber, b.episodeNumber AS toNumber
1620
+ ORDER BY fromUri, toUri, claimKey`),e.query(`MATCH (c:Cluster)<-[:MEMBER_OF]-(m:Media)-[:HAS_EPISODE]->(e:Episode)
1621
+ WHERE c.scope = 'RUN'
1622
+ RETURN c.id AS clusterId, e.uri AS uri
1623
+ ORDER BY clusterId, uri`),e.query(`MATCH (c:Cluster)<-[:MEMBER_OF]-(r:Media)-[l:LINK]-(s:Media)-[h:HAS_EPISODE]->(e:Episode)
1624
+ WHERE c.scope = 'RUN' AND l.kind = 'PART_OF' AND l.status = 'active' AND s.uri <> r.uri
1625
+ AND h.claimer = s.origin
1626
+ RETURN c.id AS clusterId, e.uri AS uri
1627
+ ORDER BY clusterId, uri`)]),l=new Map;for(let e of n){let t=String(e.id);l.set(t,(l.get(t)??new Set).add(String(e.uri)))}let u=new Map;for(let e of r){let t=String(e.runCluster);u.set(t,[...u.get(t)??[],aY(e)])}let d=new Map;for(let e of i){let t=`${String(e.runCluster)}\u0000${String(e.seasonUri)}`,n=d.get(t)??{clusterId:String(e.runCluster),kind:`season`,seasonUri:String(e.seasonUri),memberUri:String(e.memberUri),via:[],theirCount:tY(e.theirCount),retranslates:e.retranslates===!0,episodes:[]},r=eY(e.via);r&&!n.via.includes(r)&&n.via.push(r),wJ(String(e.memberUri),n.memberUri??``)<0&&(n.memberUri=String(e.memberUri)),n.episodes.some(t=>t.uri===String(e.uri))||n.episodes.push(aY(e)),d.set(t,n)}for(let e of d.values())e.via.sort(wJ);let f=new Map;for(let e of a){let t=`${String(e.runCluster)}\u0000${String(e.claimer)}`,n=f.get(t)??{clusterId:String(e.runCluster),kind:`lend`,seasonUri:null,memberUri:String(e.memberUri),via:[],theirCount:null,retranslates:oW.has(String(e.claimer)),episodes:[]};n.episodes.some(t=>t.uri===String(e.uri))||n.episodes.push(aY(e)),f.set(t,n)}let p=[],m=[],h=0,g=0,_=0,v=0;for(let n of t){let t=String(n.id),r=tY(n.runLength);if(r===null||r<1)continue;let i=l.get(t)??new Set,a=u.get(t)??[],{reference:o,origins:s}=cY({episodes:a,runLengthFrom:nY(n.runLengthFrom),runLength:r}),c=[];for(let e of d.values())e.clusterId===t&&(e.seasonUri&&i.has(e.seasonUri)||c.push(e));for(let e of f.values())e.clusterId===t&&c.push(e);let y=new Map;for(let e of a)s.has(e.origin)||y.set(e.origin,[...y.get(e.origin)??[],e]);for(let e of[...y.keys()].sort(wJ)){let n=y.get(e);sY(n,r)&&c.push({clusterId:t,kind:`member`,seasonUri:null,memberUri:null,via:[],theirCount:n.length,retranslates:oW.has(e),episodes:n})}for(let n of c.sort((e,t)=>wJ(e.kind,t.kind)||wJ(e.seasonUri??``,t.seasonUri??``)||wJ(e.episodes[0]?.uri??``,t.episodes[0]?.uri??``))){let i=ZJ({runLength:r,reference:o,candidate:n});if(!i.ok){if(v+=1,e.log({level:`info`,rule:`range:${i.reason}`,detail:`${n.kind} candidate of ${t} proved nothing`,uris:n.seasonUri?[n.seasonUri]:n.episodes.slice(0,1).map(e=>e.uri)}),n.kind!==`season`||!n.seasonUri||!n.memberUri)continue;p.push({kind:`INCLUDES`,fromUri:n.seasonUri,toUri:n.memberUri,status:`refused`,reason:i.reason,confidence:1,evidence:{reason:i.reason,theirs:n.theirCount,ours:r},supports:n.via});continue}i.rule===`dates`?h+=i.pairs.length-(i.gaps??0):i.rule===`titles`?g+=i.pairs.length:_+=i.pairs.length,g+=i.gaps??0;for(let e of i.pairs)m.push({fromUri:e.from.uri,toUri:e.to.uri,reason:QJ(e,i.rule),confidence:i.rule===`dates`?1:i.coverage,evidence:e.evidence,fromNumber:e.fromNumber,toNumber:e.toNumber,supports:[e.from.hung,e.to.hung,...n.via].filter(Boolean)});let a=n.theirCount??n.episodes.length;if(n.kind!==`season`||!n.seasonUri||!n.memberUri||a<=r)continue;let s=$J(i.pairs,a);s&&p.push({kind:`INCLUDES`,fromUri:n.seasonUri,toUri:n.memberUri,reason:i.rule,confidence:i.rule===`dates`?1:i.coverage,evidence:{rule:i.rule,theirs:a,ours:r,...i.sequence??{}},supports:n.via,range:s})}}let y=e=>{let t=new Map;for(let n of e){let e=String(n.uri),r=String(n.clusterId),i=t.get(e)??[];i.includes(r)||t.set(e,[...i,r])}return t},b=y(s),x=y(c),S=e=>({members:b.get(e)??[],attached:x.get(e)??[]}),C=new Map,w=new Set(m.map(e=>`${e.fromUri} ${e.toUri}`));for(let e of o){let t=String(e.fromUri),n=String(e.toUri);if(t===n)continue;let r=`${t} ${n}`;if(w.has(r))continue;let i=C.get(r)??{fromUri:t,toUri:n,fromNumber:tY(e.fromNumber),toNumber:tY(e.toNumber),keys:[]},a=eY(e.claimKey);a&&!i.keys.includes(a)&&i.keys.push(a),C.set(r,i)}let ee=0,te=0;for(let e of[...C.values()].sort((e,t)=>wJ(e.fromUri,t.fromUri)||wJ(e.toUri,t.toUri))){let t=oY(S(e.fromUri),S(e.toUri));t?ee+=1:te+=1,m.push({fromUri:e.fromUri,toUri:e.toUri,status:t?`active`:`refused`,reason:t?`asserted`:`foreign-episode`,confidence:1,fromNumber:e.fromNumber,toNumber:e.toNumber,supports:[...e.keys].sort(wJ)})}return(h||g||_||v||ee||te)&&e.log({level:`info`,rule:`range`,detail:`${h} pairs by date, ${g} by title, ${_} by sequence, ${v} candidates refused, ${ee} claims asserted, ${te} refused as foreign`}),{scope:{full:!0},nodes:[],edges:[],links:p,episodeLinks:m}}},uY=new Set([...JV,...YV].map(ZV)),dY=new Set([...KV,...qV].map(ZV)),fY=2e3,pY=e=>{let t=e.split(`
1628
+ `).map(e=>e.replace(/\/\/.*$/,``)).join(`
1629
+ `),n=t.indexOf(`(`),r=t.lastIndexOf(`)`);if(n<0||r<n)return[];let i=[],a=0,o=``;for(let e of t.slice(n+1,r)){if(e===`(`&&(a+=1),e===`)`&&--a,e===`,`&&a===0){i.push(o),o=``;continue}o+=e}i.push(o);let s=[];for(let e of i){let t=e.trim().replace(/\s+/g,` `);if(!t||/^FROM /i.test(t))continue;let n=/^(\w+) (.+)$/.exec(t);if(!n)continue;let r=/PRIMARY KEY/i.test(n[2]),i=n[2].replace(/PRIMARY KEY/i,``).replace(/DEFAULT .*$/i,``).trim(),a=i.endsWith(`[]`),o=/^MAP\(/i.test(i),c=a?i.slice(0,-2):o?/^MAP\(\s*[^,]+,\s*(.+?)\s*\)$/i.exec(i)?.[1]??`STRING`:i,l=a?`LIST`:o?`MAP`:i===`STRING`||i===`INT64`||i===`DOUBLE`||i===`BOOLEAN`||i===`JSON`?i:`OTHER`;s.push({name:n[1],kind:l,element:c,type:i,primary:r})}return s},mY=e=>[...e.matchAll(/FROM (\w+) TO (\w+)/g)].map(e=>({from:e[1],to:e[2]})),hY={Media:{key:`uri`,space:`uri`},Episode:{key:`uri`,space:`uri`},MediaProfile:{key:`uri`,space:`uri`},EpisodeProfile:{key:`uri`,space:`uri`},TitleKey:{key:`key`,space:`none`},Cluster:{key:`id`,space:`cluster`},Alias:{key:`id`,space:`cluster`,place:`clusterId`},Slot:{key:`id`,space:`cluster`,place:`clusterId`}},gY=new Map,_Y=new Map;for(let e of JV){let t=ZV(e),n=pY(e),r=hY[t];gY.set(t,{table:t,columns:n,key:n.find(e=>e.primary)?.name??r.key,place:r.place??r.key,space:r.space})}for(let e of YV){let t=ZV(e),n=pY(e);_Y.set(t,{table:t,columns:n,pairs:mY(e),keyed:n.some(e=>e.name===`key`)})}const vY=e=>typeof e==`number`&&Number.isSafeInteger(e),yY=(e,t)=>{if(t==null)return e.kind===`LIST`?``:null;switch(e.kind){case`STRING`:return typeof t==`string`?t:null;case`INT64`:return vY(t)?String(t):null;case`DOUBLE`:return typeof t==`number`&&Number.isFinite(t)?String(t):null;case`BOOLEAN`:return typeof t==`boolean`?String(t):null;case`JSON`:return JSON.stringify(t);case`LIST`:return Array.isArray(t)?t.map(String).join(`\0`):``;default:return null}},bY=e=>{if(typeof e!=`object`||!e)return{keys:``,values:``};let t=Object.entries(e);return{keys:t.map(([e])=>e).join(`\0`),values:t.map(([,e])=>String(e)).join(`\0`)}},xY=(e,t)=>{if(e.kind===`MAP`)return bY(t).keys?t:null;let n=yY(e,t);switch(e.kind){case`STRING`:case`JSON`:return n;case`INT64`:case`DOUBLE`:return n===null?null:Number(n);case`BOOLEAN`:return n===null?null:n===`true`;case`LIST`:return n?n.split(`\0`):null;default:return null}},SY=(e,t)=>t==null?null:e.kind===`LIST`?Array.isArray(t)&&t.length?t.map(String):null:e.kind===`INT64`||e.kind===`DOUBLE`?Number(t):t,CY=(e,t)=>Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e!==null&&t!==null&&typeof e==`object`&&typeof t==`object`?JSON.stringify(e)===JSON.stringify(t):e===t,wY=e=>{switch(e.kind){case`STRING`:case`JSON`:return`r.${e.name}`;case`INT64`:case`DOUBLE`:case`BOOLEAN`:return`cast(r.${e.name} AS ${e.type})`;case`LIST`:return`CASE WHEN r.${e.name} = '' THEN cast(NULL AS ${e.type}) ELSE ${e.element===`STRING`?`string_split(r.${e.name}, $separator)`:`cast(string_split(r.${e.name}, $separator) AS ${e.type})`} END`;case`MAP`:return`CASE WHEN r.${e.name}__keys = '' THEN cast(NULL AS ${e.type}) ELSE map(string_split(r.${e.name}__keys, $separator), ${e.element===`STRING`?`string_split(r.${e.name}__values, $separator)`:`cast(string_split(r.${e.name}__values, $separator) AS ${e.element}[])`}) END`;default:return`r.${e.name}`}},TY=(e,t)=>`${e}.${t.name} = ${wY(t)}`,EY=e=>`${e.name}: ${wY(e)}`,DY=(e,t)=>`${e}${t}`,OY=e=>{if(e.full)return{full:!0,uris:new Set,clusters:new Set,pairs:new Set,endpoints:[]};let t=new Set(e.uris);for(let[n,r]of e.pairs)t.add(n),t.add(r);return{full:!1,uris:new Set(e.uris),clusters:new Set(e.clusters),pairs:new Set(e.pairs.map(([e,t])=>DY(e,t))),endpoints:[...t]}},kY=(e,t,n)=>{if(e.space===`none`)return!1;let r=String(t[e.place]??``);return e.space===`uri`?n.uris.has(r):n.clusters.has(r)},AY=(e,t)=>{let n=String(e.__from),r=String(e.__to);if(t.pairs.has(DY(n,r)))return!0;let i=e.__fromPlace===void 0?n:String(e.__fromPlace),a=e.__toPlace===void 0?r:String(e.__toPlace);return t.uris.has(n)||t.uris.has(r)||t.clusters.has(i)||t.clusters.has(a)},jY=(e,t)=>{let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},MY=async(e,t,n,r={})=>{for(let i of jY(n,fY))i.length&&(await e(t,{...r,separator:`\0`,rows:i}),LK())},NY=(e,t)=>{let n={__key:t.key,__from:t.from??``,__to:t.to??``};for(let r of e){if(r.kind===`MAP`){let{keys:e,values:i}=bY(t.row[r.name]);n[`${r.name}__keys`]=e,n[`${r.name}__values`]=i;continue}n[r.name]=yY(r,t.row[r.name])}return n},PY=()=>({sameAs:async(e,t,n)=>{let{query:r}=await rH(),i=(await HK(r,[{fromUri:e,toUri:t,supports:n.supports}])).sameAs({fromUri:e,toUri:t,supports:n.supports});return i.ok?{ok:!0}:{ok:!1,reason:i.reason,downgrade:!!i.downgrade}},partOf:async(e,t)=>{let{query:n}=await rH(),r=(await HK(n,[{fromUri:e,toUri:t,supports:[]}])).partOf(e,t);return r.ok?{ok:!0}:{ok:!1,reason:r.reason}}}),FY=(e,t,n)=>dY.has(t)?Error(`${e} may not write ${t}: a source table is written by the ingest and by nothing else (2.3)`):uY.has(t)?Error(`${e} may not write ${t}: it declares produces { nodes: [${n.nodes.join(`, `)}], edges: [${n.edges.join(`, `)}] }`):Error(`${e} may not write ${t}: no such table in the schema of section 2`),IY=(e,t,n,r)=>WV([e,t,n,r].join(`\0`)),LY=(e,t,n)=>WV([e,t,n].join(`\0`)),RY=async e=>{let t=Date.now(),{id:n,version:r,produces:i,output:a}=e,o=e.prepare??HK,{query:s}=await rH(),c=OY(a.scope),l=[],u={},d={nodes:{},edges:{}},f=(e,t,n)=>{let r=u[e]??{created:0,updated:0,deleted:0};t===`create`&&(r.created+=1),t===`update`&&(r.updated+=1),t===`delete`&&(r.deleted+=1),u[e]=r,l.push({table:e,key:n,operation:t})},p=new Map,m=new Map;for(let e of i.nodes){if(!gY.has(e))throw FY(n,e,i);p.set(e,new Map)}for(let e of i.edges){if(!_Y.has(e))throw FY(n,e,i);m.set(e,new Map)}for(let{table:e,rows:t}of a.nodes){let a=p.get(e);if(!a)throw FY(n,e,i);let o=gY.get(e);for(let i of t){let t=i[o.key];if(typeof t!=`string`||!t)throw Error(`${n}: a ${e} row carries no ${o.key}`);a.set(t,{key:t,row:{...i,by:n,version:r}})}}for(let{table:e,rows:t}of a.edges){let a=m.get(e);if(!a)throw FY(n,e,i);let o=_Y.get(e);for(let i of t){let t=i.from,s=i.to;if(typeof t!=`string`||typeof s!=`string`||!t||!s)throw Error(`${n}: a ${e} row carries no from and to`);let c=`${t}${s}${o.keyed?String(i.key??``):``}`;a.set(c,{key:c,row:{...i,by:n,version:r},from:t,to:s})}}if(a.links.length&&!m.has(`LINK`))throw FY(n,`LINK`,i);let h=hq(a.links),g=new Set(h.map(e=>`${e.fromUri} ${e.toUri}`)),_=a.links.length||!c.full?await gq(s,n,g):[],v=await o(s,[...h.map(e=>({fromUri:e.fromUri,toUri:e.toUri,supports:e.supports})),..._.map(e=>({fromUri:e.fromUri,toUri:e.toUri,supports:e.supports}))]),y=new Map,b=async e=>{vq(y,await IY(e.fromUri,e.toUri,e.kind,n),e)};for(let e of h){if(yq(e)){await b({fromUri:e.fromUri,toUri:e.toUri,kind:e.kind,status:`refused`,reason:e.reason,confidence:e.confidence,evidence:e.evidence??null,gates:e.gates??null,range:e.range??null,supports:e.supports});continue}for(let t of _q({...e,evidence:e.evidence??null},bq(v,e)))await b(t)}for(let e of _){let t=v.sameAs({fromUri:e.fromUri,toUri:e.toUri,supports:e.supports});if(!t.ok){c.pairs.add(DY(e.fromUri,e.toUri)),c.endpoints.push(e.fromUri,e.toUri);for(let n of _q({fromUri:e.fromUri,toUri:e.toUri,kind:`SAME_AS`,reason:e.reason,confidence:1,evidence:null,supports:e.supports},t))await b(n)}}for(let e of y.values()){let t=`${e.fromUri}${e.toUri}${e.key}`;m.get(`LINK`).set(t,{key:t,from:e.fromUri,to:e.toUri,row:{key:e.key,kind:e.kind,by:n,version:r,status:e.status,reason:e.reason,confidence:e.confidence,evidence:e.evidence??null,gates:e.gates??null,fromStart:e.range?.fromStart??null,fromEnd:e.range?.fromEnd??null,toStart:e.range?.toStart??null,toEnd:e.range?.toEnd??null,contiguous:e.range?.contiguous??null,aligned:e.range?.aligned??null,total:e.range?.total??null,supports:e.supports}})}if(a.episodeLinks.length&&!m.has(`EPISODE_LINK`))throw FY(n,`EPISODE_LINK`,i);for(let e of a.episodeLinks){let t=await LY(e.fromUri,e.toUri,n),i=`${e.fromUri}${e.toUri}${t}`;m.get(`EPISODE_LINK`).set(i,{key:i,from:e.fromUri,to:e.toUri,row:{key:t,kind:`SAME_AS`,by:n,version:r,status:e.status===`refused`?`refused`:`active`,reason:e.reason,confidence:e.confidence,evidence:e.evidence??null,fromNumber:e.fromNumber,toNumber:e.toNumber,supports:e.supports}})}let x=[],S=[],C=[];for(let[e,t]of p){let r=gY.get(e),i=r.columns.map(e=>`n.${e.name} AS ${e.name}`).join(`, `),a=new Map;if(c.full)for(let t of await s(`MATCH (n:${e}) WHERE n.by = $by RETURN ${i}`,{by:n}))a.set(String(t[r.key]),t);else if(r.space!==`none`){let t=r.space===`uri`?c.endpoints:[...c.clusters];for(let o of jY(t,fY)){if(!o.length)continue;let t=await s(`UNWIND $keys AS k MATCH (n:${e} {${r.place}: k}) WHERE n.by = $by RETURN ${i}`,{keys:o,by:n});for(let e of t)a.set(String(e[r.key]),e)}}let o=[],l=[],u=[];for(let[n,i]of a)t.has(n)||!c.full&&!kY(r,i,c)||(o.push({key:n,row:i}),f(e,`delete`,n));for(let[n,i]of t){let t=a.get(n);if(!t){u.push(i),f(e,`create`,n);continue}r.columns.some(e=>!CY(xY(e,i.row[e.name]),SY(e,t[e.name])))&&(l.push(i),f(e,`update`,n))}o.length&&x.push({spec:r,rows:o}),l.length&&S.push({spec:r,rows:l}),u.length&&C.push({spec:r,rows:u}),d.nodes[e]=new Map([...t].map(([e,t])=>[e,t.row]))}let w=[],ee=[],te=[];for(let[e,t]of m){let r=_Y.get(e),i=new Map;for(let t of r.pairs){let a=hY[t.from],o=hY[t.to],l=[`a.${a.key} AS __from`,`b.${o.key} AS __to`,...a.place?[`a.${a.place} AS __fromPlace`]:[],...o.place?[`b.${o.place} AS __toPlace`]:[],...r.columns.map(e=>`e.${e.name} AS ${e.name}`)].join(`, `),u=e=>{for(let t of e){let e=`${String(t.__from)}${String(t.__to)}${r.keyed?String(t.key??``):``}`;i.set(e,t)}};if(c.full){u(await s(`MATCH (a:${t.from})-[e:${e}]->(b:${t.to}) WHERE e.by = $by RETURN ${l}`,{by:n}));continue}for(let r of jY(a.space===`none`?[]:a.space===`uri`?c.endpoints:[...c.clusters],fY))r.length&&u(await s(`UNWIND $keys AS k MATCH (a:${t.from} {${a.place??a.key}: k})-[e:${e}]->(b:${t.to})
1630
+ WHERE e.by = $by RETURN ${l}`,{keys:r,by:n}));for(let r of jY(o.space===`none`?[]:o.space===`uri`?c.endpoints:[...c.clusters],fY))r.length&&u(await s(`UNWIND $keys AS k MATCH (a:${t.from})-[e:${e}]->(b:${t.to} {${o.place??o.key}: k})
1631
+ WHERE e.by = $by RETURN ${l}`,{keys:r,by:n}))}let a=[],o=[],l=[];for(let[n,r]of i)t.has(n)||!c.full&&!AY(r,c)||(a.push({key:n,row:r,from:String(r.__from),to:String(r.__to)}),f(e,`delete`,n));for(let[n,a]of t){let t=i.get(n);if(!t){l.push(a),f(e,`create`,n);continue}r.columns.some(e=>!CY(xY(e,a.row[e.name]),SY(e,t[e.name])))&&(o.push(a),f(e,`update`,n))}a.length&&w.push({spec:r,rows:a}),o.length&&ee.push({spec:r,rows:o}),l.length&&te.push({spec:r,rows:l}),d.edges[e]=new Map([...t].map(([e,t])=>[e,t.row]))}for(let{spec:e,rows:t}of w)await UY(s,n,e,t);for(let{spec:e,rows:t}of x)await MY(s,`UNWIND $rows AS r MATCH (n:${e.table} {${e.key}: r.__key}) WHERE n.by = $by DETACH DELETE n`,t.map(e=>({__key:e.key})),{by:n});for(let{spec:e,rows:t}of C){let n=e.columns.filter(t=>t.name!==e.key).map(e=>TY(`n`,e)).join(`, `);await MY(s,`UNWIND $rows AS r MERGE (n:${e.table} {${e.key}: r.__key})
1632
+ ON CREATE SET ${n} ON MATCH SET ${n}`,t.map(t=>NY(e.columns,t)))}for(let{spec:e,rows:t}of S){let r=e.columns.filter(t=>t.name!==e.key).map(e=>TY(`n`,e)).join(`, `);await MY(s,`UNWIND $rows AS r MATCH (n:${e.table} {${e.key}: r.__key}) WHERE n.by = $by SET ${r}`,t.map(t=>NY(e.columns,t)),{by:n})}for(let{spec:e,rows:t}of te)await VY(s,n,e,t);for(let{spec:e,rows:t}of ee)await HY(s,n,e,t);return{id:n,version:r,changes:l,counts:u,ms:Date.now()-t,index:zY(e.previous,d,c,l)}},zY=(e,t,n,r)=>{if(n.full||!e)return t;let i=new Set(r.filter(e=>e.operation===`delete`).map(e=>`${e.table} ${e.key}`)),a=(e,t,n)=>{let r=new Map(t??[]);for(let t of[...r.keys()])i.has(`${e} ${t}`)&&r.delete(t);for(let[e,t]of n)r.set(e,t);return r},o={nodes:{},edges:{}};for(let[n,r]of Object.entries(t.nodes))o.nodes[n]=a(n,e.nodes[n],r);for(let[n,r]of Object.entries(t.edges))o.edges[n]=a(n,e.edges[n],r);return o},BY=(e,t)=>`MATCH (a:${t.from} {${hY[t.from].key}: r.__from})-[e:${e}]->(b:${t.to} {${hY[t.to].key}: r.__to})`,VY=async(e,t,n,r)=>{let i=n.columns.map(EY).join(`, `),a=n.keyed?`{key: r.key, by: $by}`:`{by: $by}`;for(let o of n.pairs)await MY(e,`UNWIND $rows AS r
1633
+ MATCH (a:${o.from} {${hY[o.from].key}: r.__from}), (b:${o.to} {${hY[o.to].key}: r.__to})
1634
+ WHERE NOT EXISTS { MATCH (a)-[:${n.table} ${a}]->(b) }
1635
+ CREATE (a)-[:${n.table} {${i}}]->(b)`,r.map(e=>NY(n.columns,e)),{by:t})},HY=async(e,t,n,r)=>{let i=n.columns.filter(e=>e.name!==`key`).map(e=>TY(`e`,e)).join(`, `);if(i)for(let a of n.pairs)await MY(e,`UNWIND $rows AS r ${BY(n.table,a)}
1636
+ WHERE e.by = $by${n.keyed?` AND e.key = r.key`:``} SET ${i}`,r.map(e=>NY(n.columns,e)),{by:t})},UY=async(e,t,n,r)=>{for(let i of n.pairs)await MY(e,`UNWIND $rows AS r ${BY(n.table,i)}
1637
+ WHERE e.by = $by${n.keyed?` AND e.key = r.key`:``} DELETE e`,r.map(e=>({__from:e.from,__to:e.to,key:e.row.key??null})),{by:t})},WY=[`CREATE`,`MERGE`,`SET`,`DELETE`,`DETACH`,`REMOVE`,`DROP`,`ALTER`,`COPY`,`CALL`,`LOAD`,`IMPORT`,`EXPORT`,`ATTACH`],GY=e=>e.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"/g,`''`),KY=(e,t)=>{let n=GY(t);if(n.includes(`;`))throw Error(`${e}: a plugin query may not carry ';' (5.3): ${t.slice(0,80)}`);for(let r of WY)if(RegExp(`\\b${r}\\b`,`i`).test(n))throw Error(`${e}: a plugin query may not carry ${r} (5.3): ${t.slice(0,80)}`)},qY=(e,t)=>async(n,r)=>(KY(e,n),await t(n,r)),JY=[{table:`Media`,kind:`node`,seq:`seq`,key:`uri`,unique:!0,hash:`hash`,content:`raw`,columns:[`owned`,`scope`,`origin`,`id`]},{table:`Episode`,kind:`node`,seq:`seq`,key:`uri`,unique:!0,hash:`hash`,content:`raw`,columns:[`origin`,`id`,`mediaUri`]},{table:`Origin`,kind:`node`,seq:`seq`,key:`id`,unique:!0,hash:`hash`,content:`raw`,columns:[]},{table:`Answer`,kind:`node`,seq:`seq`,key:`key`,unique:!0,columns:[`uri`,`origin`,`kind`,`operation`,`raw`]},{table:`Ask`,kind:`node`,seq:`seq`,key:`key`,unique:!0,columns:[`runUri`,`origin`,`showId`,`outcome`,`reason`,`answerUri`]},{table:`CLAIMS`,kind:`edge`,seq:`seq`,key:`key`,unique:!0,hash:`hash`,content:`node`,columns:[`kind`,`provenance`,`claimer`,`targetScope`]},{table:`HAS_EPISODE`,kind:`edge`,seq:`seq`,key:`key`,unique:!0,columns:[`claimer`]},{table:`EPISODE_CLAIMS`,kind:`edge`,seq:`seq`,key:`key`,unique:!0,columns:[`kind`,`provenance`,`claimer`,`node`]},{table:`RELATED`,kind:`edge`,seq:`answerSeq`,key:`relation`,columns:[`format`,`claimer`,`node`]}],YY=(e,t)=>e.kind===`node`?`MATCH (${t}:${e.table})`:`MATCH ()-[${t}:${e.table}]->()`,XY=async e=>{let{query:t}=await rH(),n={bounds:{...e},tables:{},entries:{},mismatches:[]};for(let e of JY){let r=e.kind===`node`?`n`:`e`;if(n.bounds[e.table]===void 0){let[i]=await t(`${YY(e,r)} RETURN max(${r}.${e.seq}) AS bound`);n.bounds[e.table]=Number(i?.bound??0)}let i=n.bounds[e.table],a=[...new Set([e.key,e.seq,...e.columns,...e.hash?[e.hash]:[],...e.content?[e.content]:[]])],o=a.map(e=>`${r}.${e} AS ${e}`).join(`, `),s=await t(`${YY(e,r)} RETURN ${o}`),c=new Map,l=[];for(let t of s){let r=``;if(e.hash&&e.content){let i=t[e.content];typeof i==`string`&&i&&(r=await GV(JSON.parse(i)),r!==t[e.hash]&&n.mismatches.push(`${e.table} ${String(t[e.key])}: stored hash does not match its own ${e.content}`))}let o=[...a.filter(t=>t!==e.seq).map(e=>String(t[e]??``)),r].join(` `),s=t[e.seq]===null||t[e.seq]===void 0?null:Number(t[e.seq]);c.set(e.unique?String(t[e.key]):o,{seq:s,witness:o}),s!==null&&s<=i&&l.push(o)}l.sort(),n.entries[e.table]=c,n.tables[e.table]={rows:l.length,witness:await WV(l.join(`
1638
+ `))}}return n},ZY=(e,t)=>{let n=[];for(let r of JY){let i=e.bounds[r.table]??0,a=e.entries[r.table],o=t.entries[r.table];if(!(!a||!o)){for(let[e,t]of a){if(t.seq===null||t.seq>i)continue;let a=o.get(e);if(!a){n.push(`${r.table} ${e}: the row was deleted during the pass, inside seq <= ${i}`);continue}a.seq!==null&&a.seq>i||a.witness!==t.witness&&n.push(`${r.table} ${e}: the row changed during the pass, inside seq <= ${i}`)}for(let[e,t]of o)a.has(e)||(t.seq===null?n.push(`${r.table} ${e}: a row carrying no seq appeared during the pass`):t.seq<=i&&n.push(`${r.table} ${e}: a row appeared inside seq <= ${i} during the pass`))}}for(let r of t.mismatches)e.mismatches.includes(r)||n.push(r);return n},QY=e=>{let t=[...e],n=new Set,r=[];for(;t.length;){let i=t.findIndex(t=>t.after.every(t=>n.has(t)||!e.some(e=>e.id===t))),[a]=t.splice(i<0?0:i,1);r.push(a),n.add(a.id)}return r},$Y=e=>{let t=e.indexOf(`#`);return t<0?e:e.slice(0,t)},eX=(e,t)=>{let n=e.get(t);if(n)return n;let r={media:new Set,episodes:new Set,claims:new Set,links:new Set,clusters:new Set};return e.set(t,r),r},tX=(e,t,n,r)=>{let i=eX(e,t);n!==`none`&&r&&i[n].add(r)},nX=e=>{if(e.reason!==`graph:changed`||!e.uris&&!e.episodes&&!e.claims)return;let t=new Map;for(let n of e.uris??[])tX(t,`Media`,`media`,n),tX(t,`Answer`,`media`,n),tX(t,`ABOUT`,`media`,n);for(let n of e.episodes??[])tX(t,`Episode`,`episodes`,n),tX(t,`HAS_EPISODE`,`episodes`,n),tX(t,`Answer`,`episodes`,n),tX(t,`ABOUT`,`episodes`,n);for(let n of e.claims??[])tX(t,`CLAIMS`,`claims`,n);return t},rX=e=>{let t=new Map;for(let n of e){let[e=``,r=``]=n.key.split(`\0`),i=n.table;switch(i){case`MediaProfile`:tX(t,i,`media`,n.key);break;case`EpisodeProfile`:tX(t,i,`episodes`,n.key);break;case`Cluster`:tX(t,i,`clusters`,n.key);break;case`Slot`:tX(t,i,`clusters`,$Y(n.key));break;case`HAS_KEY`:tX(t,i,`media`,e);break;case`MEMBER_OF`:tX(t,i,`media`,e),tX(t,i,`clusters`,r);break;case`ATTACHED_TO`:tX(t,i,`clusters`,e),tX(t,i,`clusters`,r);break;case`SLOT_OF`:tX(t,i,`clusters`,r),tX(t,i,`clusters`,$Y(e));break;case`FILLS`:tX(t,i,`media`,e),tX(t,i,`episodes`,e),tX(t,i,`clusters`,$Y(r));break;case`LINK`:tX(t,i,`media`,e),tX(t,i,`media`,r),tX(t,i,`links`,n.key);break;case`EPISODE_LINK`:tX(t,i,`episodes`,e),tX(t,i,`episodes`,r),tX(t,i,`links`,n.key);break;default:tX(t,i,`none`);break}}return t},iX=(e,t)=>{let n=[...e.consumes.nodes,...e.consumes.edges].filter(e=>t.has(e));if(!n.length)return;let r={media:[],episodes:[],claims:[],links:[],clusters:[],full:!1},i={media:new Set,episodes:new Set,claims:new Set,links:new Set,clusters:new Set};for(let e of n){let n=t.get(e);for(let e of[`media`,`episodes`,`claims`,`links`,`clusters`])for(let t of n[e])i[e].add(t)}for(let e of[`media`,`episodes`,`claims`,`links`,`clusters`])r[e]=[...i[e]];return r},aX=()=>({media:[],episodes:[],claims:[],links:[],clusters:[],full:!0}),oX=()=>({media:[],episodes:[],claims:[],links:[],clusters:[],full:!1}),sX=new Map,cX=new Map,lX=new Map,uX=async(e,t,n={})=>{let r=Date.now(),i=Date.now(),{query:a}=await rH(),o=n.audit===!1?void 0:await XY(),s=o?.bounds??{},c=Math.max(0,...Object.values(s)),l=Date.now()-i,u=QY(e),d=PY(),f=[],p=[],m=[],h=[],g=[],_=new Set,v=0,y=nX(t);for(let e=1;e<=4;e+=1){v=e;let t=[];for(let n of u){let r=y?iX(n,y):void 0;if(y&&!r&&lX.get(n.id)===!1){f.push({id:n.id,iteration:e,ms:0,changes:0,skipped:!0});continue}let i=Date.now(),o={id:n.id,query:qY(n.id,a),since:sX.get(n.id)??0,passStart:c,delta:y?r??oX():aX(),guards:d,previous:cX.get(n.id)??{nodes:{},edges:{}},titleSimilarity:ET,maxPossibleSimilarity:HG,parseSeasonNumber:Yw,isOnlySeasonLabel:Jw,isGenericEpisodeTitle:UD,log:e=>g.push(e)};try{let r=await n.run(o);lX.set(n.id,r.scope.full);let a=await RY({id:n.id,version:n.version,produces:n.produces,output:r,previous:cX.get(n.id)});cX.set(n.id,a.index),sX.set(n.id,c),t.push(...a.changes),f.push({id:n.id,iteration:e,ms:Date.now()-i,changes:a.changes.length})}catch(t){let r=t instanceof Error?t.message:String(t);f.push({id:n.id,iteration:e,ms:Date.now()-i,changes:0,failed:r}),h.push({rule:`plugin-failed`,detail:`${n.id} threw and its previous output stands: ${r}`})}}if(p.push(...t),!t.length)break;y=rX(t);let n=await dX(t);if(m.push(n),_.has(n)){h.push({rule:`fixed-point-cap`,detail:`the applied deltas repeat at iteration ${e}, so the pass stopped on a cycle`});break}_.add(n),e===4&&h.push({rule:`fixed-point-cap`,detail:`a pass hit the cap of 4 iterations and stopped before a fixed point`})}let b=Date.now(),x=o?await XY(s):void 0,S=o&&x?ZY(o,x):[];for(let e of S)h.push({rule:`source-mutated`,detail:e});return{trigger:t,iterations:v,runs:f,changes:p,stateHashes:m,anomalies:h,logs:g,audit:{ok:!S.length,bounds:s,before:o??{bounds:s,tables:{},entries:{},mismatches:[]},after:x??{bounds:s,tables:{},entries:{},mismatches:[]},differences:S,ms:l+(x?Date.now()-b:0)},ms:Date.now()-r}},dX=e=>WV(e.map(e=>[e.table,e.operation,e.key].join(` `)).sort().join(`
1639
+ `)),fX=e=>{let t=Yw(e);if(t===void 0||t<2)return;let n=mT(Kw.reduce((e,t)=>e.replace(t,` `),e));if(!(!n||n===e))return n},pX=[`format`,`season`,`date`,`companion`],mX=(e,t)=>e<t?-1:+(e>t),hX=e=>typeof e==`string`&&e?e:null,gX=e=>e==null||e===``?null:Number.isFinite(Number(e))?Number(e):null,_X=e=>{if(!(typeof e!=`string`||!e))try{return JSON.parse(e)}catch{return}},vX=e=>{let t=_X(e);if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=hX(e?.key);if(!t)continue;let r=hX(e?.class)??`MAIN`;r===`MAIN`&&n.push({key:t,score:gX(e?.score),class:r})}return n},yX=e=>{let t=new Map;for(let n of e){let e=t.get(n.cluster);e?e.push(n):t.set(n.cluster,[n])}let n=new Map;for(let[e,r]of t){let t=r.every(e=>e.clusterScope===`CONTAINER`)?`CONTAINER`:`RUN`,i=t===`CONTAINER`?`container`:`run`,a=new Map,o=new Set,s=new Set,c=new Set,l=new Set,u=new Set,d=!1;for(let e of r){for(let t of vX(e.titleKeys)){let e=t.score??-1,n=a.get(t.key);(n===void 0||e>n)&&a.set(t.key,e)}if(e.dateSubject===i){let t=gX(e.year),n=gX(e.startDay);t!==null&&o.add(t),n!==null&&s.add(n)}let t=hX(e.format),n=hX(e.workKind),r=gX(e.seasonOrdinal)??gX(e.partOrdinal);t&&c.add(t),n&&l.add(n),r!==null&&u.add(r),e.companion===!0&&(d=!0)}let f=BG(a),p=new Set;if(t===`RUN`)for(let e of f){let t=fX(e);t&&p.add(t)}let m=r.map(e=>e.uri).sort(mX),h=r.filter(e=>(e.memberScope===`CONTAINER`?`CONTAINER`:`RUN`)===t).map(e=>e.uri).sort(mX)[0]??m[0];n.set(e,{id:e,scope:t,linkUri:h,titles:f,keys:new Set(f),years:o,days:s,formats:c,workKinds:l,seasons:u,companion:d,containerKeys:p,laterRun:[...u].some(e=>e>=2),cacheKey:`${e}#${t}#${[...f].sort(mX).join(`,`)}#${[...c].sort(mX).join(`,`)}#${[...u].sort((e,t)=>e-t).join(`,`)}#${[...s].sort((e,t)=>e-t).join(`,`)}#${[...l].sort(mX).join(`,`)}`})}return n},bX=(e,t)=>![...e].some(e=>t.has(e)),xX=(e,t)=>{let n=(e,t)=>[...e.containerKeys].some(e=>t.keys.has(e));if(e.scope===`RUN`&&t.scope===`CONTAINER`&&e.laterRun&&n(e,t))return e;if(t.scope===`RUN`&&e.scope===`CONTAINER`&&t.laterRun&&n(t,e))return t},SX=(e,t)=>({format:e.formats.size&&t.formats.size?bX(e.formats,t.formats)?`refused`:`passed`:`silent`,season:e.seasons.size&&t.seasons.size?bX(e.seasons,t.seasons)?`refused`:`passed`:`silent`,date:e.days.size&&t.days.size&&!xX(e,t)?[...e.days].some(e=>[...t.days].some(t=>Math.abs(e-t)<=45))?`passed`:`refused`:`silent`,companion:e.workKinds.size&&t.workKinds.size?bX(e.workKinds,t.workKinds)&&(e.companion||t.companion)&&LG(e.titles,t.titles)?`refused`:`passed`:`silent`}),CX=async(e,t,n)=>{for(let r of e.titles)for(let e of t.titles){if(r===e)return{titleA:r,titleB:e,similarity:1,exact:!0};if(WG(r,e)||n.maxPossibleSimilarity(r,e)<.9)continue;let t=await n.titleSimilarity(r,e);if(t>=.9)return{titleA:r,titleB:e,similarity:t,exact:!1}}return wX(e,t)},wX=(e,t)=>{let n=e.scope===`RUN`&&t.scope===`CONTAINER`?e:t.scope===`RUN`&&e.scope===`CONTAINER`?t:void 0;if(!n||!n.containerKeys.size)return;let r=n===e?t:e;for(let e of n.titles){let t=fX(e);if(!(!t||!r.keys.has(t)))return{titleA:e,titleB:t,similarity:1,exact:!1,via:`ordinal`}}},TX=(e,t)=>e.scope===t.scope?mX(e.linkUri,t.linkUri)<=0?[e,t]:[t,e]:e.scope===`RUN`?[e,t]:[t,e],EX=(e,t)=>{let n=null;for(let r of e.years)t.years.has(r)&&(n===null||r<n)&&(n=r);return n},DX=(e,t)=>{let n=null;for(let r of e.days)for(let e of t.days){let t=Math.abs(r-e);(n===null||t<n)&&(n=t)}return n},OX=(e=>{let t=new Map;return{get:e=>{let n=t.get(e);if(n!==void 0)return t.delete(e),t.set(e,n),n},set:(n,r)=>{for(t.delete(n),t.set(n,r);t.size>e;){let e=t.keys().next();if(e.done)break;t.delete(e.value)}},get size(){return t.size}}})(5e4),kX=async(e,t,n,r=OX)=>{let i=`${e.cacheKey}|${t.cacheKey}`,a=r.get(i);if(a)return a;let o=SX(e,t),s={gates:o,refusedBy:pX.find(e=>o[e]===`refused`)??null,match:await CX(e,t,n),year:EX(e,t),daysDelta:DX(e,t)};return r.set(i,s),s},AX=(e,t,n)=>{if(!n.match)return;let{titleA:r,titleB:i,similarity:a,exact:o,via:s}=n.match;return{kind:`SAME_AS`,fromUri:e.linkUri,toUri:t.linkUri,...n.refusedBy?{status:`refused`}:{},reason:n.refusedBy??(s===`ordinal`?`ordinal`:o?`exact`:`similar`),confidence:a,evidence:{titleA:r,titleB:i,similarity:a,...s===`ordinal`?{via:s}:{},year:n.year,daysDelta:n.daysDelta},gates:n.gates,supports:[r,i]}},jX=(e,t)=>mX(e,t)<=0?`${e} ${t}`:`${t} ${e}`,MX=[SK,CJ,{id:`plugin:title`,consumes:{nodes:[`Cluster`,`MediaProfile`,`TitleKey`],edges:[`MEMBER_OF`,`HAS_KEY`]},produces:{nodes:[],edges:[`LINK`],kinds:[`SAME_AS`,`PART_OF`]},after:[`plugin:aggregate`,`plugin:containment`],version:2,run:async e=>{let t=yX(await e.query(`MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster)
1640
+ MATCH (p:MediaProfile)-[:PROFILE_OF]->(m)
1641
+ RETURN c.id AS cluster, c.scope AS clusterScope, m.uri AS uri, p.scope AS memberScope,
1642
+ p.dateSubject AS dateSubject, p.titleKeys AS titleKeys, p.year AS year, p.startDay AS startDay,
1643
+ p.format AS format, p.workKind AS workKind, p.seasonOrdinal AS seasonOrdinal,
1644
+ p.partOrdinal AS partOrdinal, p.companion AS companion
1645
+ ORDER BY cluster, uri`)),n=new Map;for(let e of t.values())if(e.titles.length)for(let t of e.years){let r=n.get(t);r?r.push(e.id):n.set(t,[e.id])}let r=new Map;for(let e of t.values())if(e.scope===`CONTAINER`)for(let t of e.keys){let n=r.get(t);n?n.push(e.id):r.set(t,[e.id])}let i=new Map;for(let e of[...n.keys()].sort((e,t)=>e-t)){let t=[...n.get(e)].sort(mX);for(let e=0;e<t.length;e+=1)for(let n=e+1;n<t.length;n+=1)i.set(jX(t[e],t[n]),[t[e],t[n]])}let a=0;for(let e of[...t.keys()].sort(mX)){let n=t.get(e);if(n.containerKeys.size)for(let e of[...n.containerKeys].sort(mX))for(let t of r.get(e)??[]){if(t===n.id)continue;let e=jX(n.id,t);i.has(e)||(a+=1),i.set(e,[n.id,t])}}let o=[...t.keys()].sort(mX),s=0,c=o.length?await e.query(`UNWIND $clusters AS cid
1646
+ MATCH (ca:Cluster {id: cid})<-[:MEMBER_OF]-(a:Media)-[:HAS_KEY {class: 'MAIN'}]->(t:TitleKey)<-[:HAS_KEY {class: 'MAIN'}]-(b:Media)-[:MEMBER_OF]->(cb:Cluster)
1647
+ WHERE cb.id <> ca.id
1648
+ MATCH (pa:MediaProfile)-[:PROFILE_OF]->(:Media)-[:MEMBER_OF]->(ca),
1649
+ (pb:MediaProfile)-[:PROFILE_OF]->(:Media)-[:MEMBER_OF]->(cb)
1650
+ WHERE pa.year IS NOT NULL AND pb.year = pa.year
1651
+ AND ((ca.scope = 'CONTAINER' AND pa.dateSubject = 'container') OR (ca.scope <> 'CONTAINER' AND pa.dateSubject = 'run'))
1652
+ AND ((cb.scope = 'CONTAINER' AND pb.dateSubject = 'container') OR (cb.scope <> 'CONTAINER' AND pb.dateSubject = 'run'))
1653
+ RETURN DISTINCT ca.id AS fromCluster, cb.id AS toCluster, t.key AS shared, pa.year AS year
1654
+ ORDER BY fromCluster, toCluster, shared`,{clusters:o}):[];for(let e of c){let n=t.get(String(e.fromCluster)),r=t.get(String(e.toCluster));if(!n||!r)continue;let a=String(e.shared);!n.keys.has(a)||!r.keys.has(a)||(s+=1,i.set(jX(n.id,r.id),[n.id,r.id]))}let l=[],u=new Set,d=0;for(let[n,r]of[...i.keys()].sort(mX).map(e=>i.get(e))){let[i,a]=TX(t.get(n),t.get(r)),o=await kX(i,a,e),s=AX(i,a,o);s&&(o.refusedBy&&(d+=1),u.add(jX(s.fromUri,s.toUri)),l.push(s))}let f=0;for(let t of await e.query(`MATCH (a:Media)-[l:LINK]->(b:Media)
1655
+ WHERE l.by = $by AND l.kind = 'SAME_AS' AND l.status = 'active'
1656
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.reason AS reason, l.confidence AS confidence,
1657
+ l.evidence AS evidence, l.gates AS gates, l.supports AS supports
1658
+ ORDER BY fromUri, toUri`,{by:e.id})){let e=String(t.fromUri),n=String(t.toUri);u.has(jX(e,n))||(f+=1,l.push({kind:`SAME_AS`,fromUri:e,toUri:n,reason:hX(t.reason)??`exact`,confidence:gX(t.confidence)??1,evidence:_X(t.evidence)??null,gates:_X(t.gates),supports:Array.isArray(t.supports)?t.supports.map(String):[]}))}return e.log({level:`info`,rule:`title-scan`,detail:`${t.size} clusters, ${n.size} year buckets, ${i.size} pairs (${s} through the exact key, ${a} through the ordinal axis), ${l.length-f} proposals of which ${d} refused by a gate, ${f} carried, cache ${OX.size}`}),{scope:{full:!0},nodes:[],edges:[],links:l,episodeLinks:[]}}},Gq,lY,_J];let NX=MX,PX=!1,FX,IX,LX,RX=null,zX=[],BX={wakes:0,passes:0,audits:0,totalMs:0,longestMs:0};const VX=e=>{let t=e.indexOf(`#`);return t<0?e:e.slice(0,t)},HX=async e=>{let t=new Set,n=new Set,r=new Set,i=new Set;for(let a of e){let[e=``,o=``]=a.key.split(`\0`);switch(a.table){case`Cluster`:t.add(a.key);break;case`Slot`:t.add(VX(a.key));break;case`Alias`:n.add(a.key);break;case`MEMBER_OF`:case`SLOT_OF`:t.add(o);break;case`ATTACHED_TO`:t.add(e),t.add(o);break;case`FILLS`:t.add(VX(o));break;case`LINK`:r.add(e),r.add(o);break;case`EPISODE_LINK`:i.add(e),i.add(o);break;default:break}}let{query:a}=await rH();if(n.size){let e=await a(`UNWIND $ids AS i MATCH (a:Alias {id: i}) RETURN a.clusterId AS clusterId`,{ids:[...n]});for(let n of e)typeof n.clusterId==`string`&&t.add(n.clusterId)}if(r.size){let e=await a(`UNWIND $uris AS u MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster) RETURN c.id AS id`,{uris:[...r]});for(let n of e)t.add(String(n.id))}if(i.size){let e=await a(`UNWIND $uris AS u MATCH (e:Episode {uri: u})<-[:HAS_EPISODE]-(m:Media)-[:MEMBER_OF]->(c:Cluster) RETURN c.id AS id`,{uris:[...i]});for(let n of e)t.add(String(n.id))}let o=[...t].filter(Boolean).sort();if(!o.length)return{clusters:[],uris:[]};let s=await a(`UNWIND $ids AS i MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster {id: i}) RETURN m.uri AS uri`,{ids:o});return{clusters:o,uris:[...new Set(s.map(e=>String(e.uri)))].sort()}},mee=async()=>{try{for(;IX;){let e=IX;IX=void 0,BX.passes+=1;let t=PX||BX.passes%16==0;t&&(BX.audits+=1);let n={reason:e.reason,seq:e.seq,uris:[...e.uris].sort(),...e.episodes.size?{episodes:[...e.episodes].sort()}:{},...e.claimKeys.size?{claims:[...e.claimKeys].sort()}:{}};try{let r=await uX(NX,n,{audit:t});if(RX=r,BX.totalMs+=r.ms,BX.longestMs=Math.max(BX.longestMs,r.ms),r.changes.length){let e=await HX(r.changes);e.clusters.length&&JL(`view:changed`,e)}for(let t of e.claims)t.resolve(r)}catch(t){console.error(Error(`graph: a pass failed; the wake behind it still runs`,{cause:t}));for(let n of e.claims)n.reject(t)}}}finally{LX=void 0;let e=zX;zX=[];for(let t of e)t(RX)}},UX=(e,t,n)=>{BX.wakes+=1;let r=IX??{reason:e,seq:0,uris:new Set,episodes:new Set,claimKeys:new Set,claims:[]};r.seq=Math.max(r.seq,t.seq??0);for(let e of t.uris??[])r.uris.add(e);for(let e of t.episodes??[])r.episodes.add(e);for(let e of t.claims??[])r.claimKeys.add(e);n&&r.claims.push(n),IX=r,LX??=mee()},WX=(e={})=>{FX&&GX(),NX=e.plugins??MX,PX=e.audit===!0,BX={wakes:0,passes:0,audits:0,totalMs:0,longestMs:0},RX=null,FX=[YL(`graph:changed`,e=>UX(`graph:changed`,e)),YL(`row:changed`,e=>UX(`graph:changed`,e))]},GX=()=>{for(let e of FX??[])e();FX=void 0},KX=e=>new Promise((t,n)=>{UX(e,{},{resolve:t,reject:n})}),qX=()=>!LX&&!IX?Promise.resolve(RX):new Promise(e=>{zX.push(e)}),JX=e=>typeof e==`string`&&e?e:null,YX=e=>{let t=[];for(let n of Object.values(e)){let e=n??{},r=JX(e.origin),i=JX(e.name);!r||!i||t.push({id:r,name:i,url:JX(e.originUrl),icon:JX(e.icon),color:JX(e.color),isApiOnly:e.isApiOnly===!0})}return t.sort((e,t)=>e.id<t.id?-1:+(e.id>t.id))},XX=async e=>{let{query:t}=await rH(),n=e??await Promise.resolve().then(()=>OL),r=YX(n);if(!r.length)return 0;await t(`UNWIND $rows AS r
1659
+ MERGE (o:Origin {id: r.id})
1660
+ ON CREATE SET o.raw = r.raw, o.hash = r.hash, o.seq = cast('0' AS INT64)`,{rows:await Promise.all(r.map(async e=>{let t={id:e.id,url:e.url,name:e.name,icon:e.icon,color:e.color,isApiOnly:e.isApiOnly};return{id:e.id,raw:JSON.stringify(t),hash:await GV(t)}}))});let[i]=await t(`MATCH (o:Origin) RETURN count(o) AS total`);return Number(i?.total??0)},ZX=async()=>{if(!zV())throw Error(`graph: the graph is off, load the page with ?graph=1`);await TH(),await qX();let{query:e}=await rH(),t={};for(let n of $V){let r=await e(`MATCH (n:${n}) RETURN count(n) AS total`);t[n]=Number(r[0]?.total??0)}for(let n of eH){let r=await e(`MATCH ()-[e:${n}]->() RETURN count(e) AS total`);t[n]=Number(r[0]?.total??0)}return t},QX=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[],W=e=>typeof e==`string`?e:``,$X=e=>typeof e==`string`&&e?e:null,eZ=e=>typeof e==`number`&&Number.isFinite(e)?e:null,tZ=e=>{if(typeof e!=`string`||!e)return null;try{return JSON.parse(e)}catch{return console.error(Error(`graph trace: a column is not JSON: ${e.slice(0,80)}`)),null}},nZ=e=>{if(!Array.isArray(e))return null;let t=e.filter(e=>typeof e==`object`&&!!e).filter(e=>typeof e.title==`string`&&e.title).sort((e,t)=>(eZ(t.score)??0)-(eZ(e.score)??0)||W(e.language).localeCompare(W(t.language))||String(e.title).localeCompare(String(t.title)));return t.length?String(t[0].title):null},rZ=e=>nZ(tZ(e)),iZ=e=>typeof e==`string`?new TextEncoder().encode(e).length:0,aZ=e=>{let t=qY(`graph trace`,e),n=0;return{read:async(e,r)=>(n+=1,t(e,r)),spent:()=>n}},oZ=`RETURN DISTINCT c.id AS id, c.key AS key,
1661
+ CASE WHEN c.scope = 'RUN' THEN 0 ELSE 1 END AS scopeRank
1662
+ ORDER BY scopeRank, key
1663
+ LIMIT 1`,sZ=async(e,t,n)=>{if(n.length){let[t]=await e(`UNWIND $uris AS u MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster) ${oZ}`,{uris:[...n]});if(t)return String(t.id);let[r]=await e(`UNWIND $uris AS u MATCH (c:Cluster) WHERE u IN c.published ${oZ}`,{uris:[...n]});if(r)return String(r.id)}if(!t)return null;let[r]=await e(`MATCH (c:Cluster {id: $id}) RETURN c.id AS id`,{id:t});if(r)return String(r.id);let[i]=await e(`MATCH (x:Alias {id: $id}) MATCH (c:Cluster {id: x.clusterId}) RETURN c.id AS id`,{id:t});return i?String(i.id):null},cZ=async e=>{let t={};for(let n of $V){let r=await e(`MATCH (n:${n}) RETURN count(n) AS total`);t[n]=eZ(r[0]?.total)??0}for(let n of eH){let r=await e(`MATCH ()-[e:${n}]->() RETURN count(e) AS total`);t[n]=eZ(r[0]?.total)??0}return t},lZ=()=>({value:null,from:null,tier:null,witnesses:null}),uZ=(e,t,n,r)=>({asked:e,resolved:null,reason:t,members:[],claims:[],links:[],attachments:[],episodes:[],episodeLinks:[],episodeClaims:[],episodeSources:[],runLength:lZ(),anomalies:[],asks:[],answers:[],counts:n,cost:r}),dZ=async e=>{let t=e??``,n=performance.now();if(!zV())return uZ(t,`not-enabled`,{},{statements:0,ms:0});let{query:r}=await rH(),{read:i,spent:a}=aZ(r),o=()=>({statements:a(),ms:Math.round(performance.now()-n)}),s=rU(t),c=await cZ(i),l=await sZ(i,t,s);if(!l){if((c.Media??0)===0)return uZ(t,`graph-empty`,c,o());let e=s.length?await i(`MATCH (m:Media) WHERE m.uri IN $uris RETURN m.uri AS uri LIMIT 1`,{uris:[...s]}):[];return uZ(t,e.length?`no-cluster`:`no-row`,c,o())}let u=(s.length>1?await i(`UNWIND $uris AS u MATCH (m:Media {uri: u})-[:MEMBER_OF]->(c:Cluster)
1664
+ RETURN DISTINCT c.id AS id ORDER BY id`,{uris:[...s]}):[]).map(e=>W(e.id)).filter(e=>e&&e!==l),[d]=await i(`MATCH (c:Cluster {id: $id})
1665
+ RETURN c.aggUri AS aggUri, c.scope AS scope, c.kind AS kind, c.runLength AS runLength,
1666
+ c.runLengthTier AS tier, c.runLengthWitnesses AS witnesses,
1667
+ c.runLengthFrom AS witnessedBy, c.anomalies AS anomalies`,{id:l}),f=await i(`MATCH (m:Media)-[:MEMBER_OF]->(c:Cluster {id: $id})
1668
+ OPTIONAL MATCH (p:MediaProfile {uri: m.uri})
1669
+ RETURN m.uri AS uri, m.origin AS origin, m.owned AS owned, m.titles AS titles,
1670
+ m.episodeCount AS episodeCount, m.startDate AS startDate,
1671
+ coalesce(p.scope, m.scope) AS scope, p.countKind AS countKind
1672
+ ORDER BY uri`,{id:l}),p=await i(`MATCH (c:Cluster {id: $id})<-[:MEMBER_OF]-(:Media)-[:CLAIMS]->(t:Media {owned: false})
1673
+ WHERE NOT t.uri IN $members
1674
+ RETURN DISTINCT t.uri AS uri, t.origin AS origin
1675
+ ORDER BY uri`,{id:l,members:f.map(e=>W(e.uri))}),m=[...f.map(e=>({uri:W(e.uri),origin:W(e.origin),owned:e.owned===!0,scope:$X(e.scope),title:rZ(e.titles),episodeCount:eZ(e.episodeCount),countKind:$X(e.countKind),startDate:$X(e.startDate),via:`member`})),...p.map(e=>({uri:W(e.uri),origin:W(e.origin),owned:!1,scope:null,title:null,episodeCount:null,countKind:null,startDate:null,via:`placeholder`}))],h=m.map(e=>e.uri),g=h.length?await i(`MATCH (a:Media)-[cl:CLAIMS]->(b:Media)
1676
+ WHERE a.uri IN $uris AND b.uri IN $uris
1677
+ RETURN a.uri AS fromUri, b.uri AS toUri, cl.kind AS kind, cl.claimer AS claimer,
1678
+ cl.provenance AS provenance, cl.answerSeq AS answerSeq, cl.targetScope AS targetScope,
1679
+ cl.key AS key
1680
+ ORDER BY fromUri, toUri, kind, claimer`,{uris:h}):[],_=h.length?await i(`MATCH (a:Media)-[l:LINK]->(b:Media)
1681
+ WHERE a.uri IN $uris OR b.uri IN $uris
1682
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.kind AS kind, l.status AS status, l.by AS by,
1683
+ l.reason AS reason, l.confidence AS confidence, l.version AS version,
1684
+ l.evidence AS evidence, l.gates AS gates, l.supports AS supports, l.key AS key
1685
+ ORDER BY fromUri, toUri, kind, by`,{uris:h}):[],v=await i(`MATCH (a:Cluster)-[t:ATTACHED_TO]->(b:Cluster)
1686
+ WHERE a.id = $id OR b.id = $id
1687
+ RETURN a.id AS fromId, b.id AS toId, a.aggUri AS fromUri, b.aggUri AS toUri,
1688
+ t.via AS via, t.by AS by, t.supports AS supports
1689
+ ORDER BY fromId, toId`,{id:l}),y=await i(`MATCH (s:Slot)-[:SLOT_OF]->(c:Cluster {id: $id})
1690
+ OPTIONAL MATCH (e:Episode)-[f:FILLS]->(s)
1691
+ RETURN s.id AS slotId, s.number AS number, s.episode AS episode, e.uri AS episodeUri,
1692
+ e.origin AS origin, f.via AS via, f.by AS by, f.number AS fillNumber,
1693
+ f.supports AS supports
1694
+ ORDER BY slotId, episodeUri`,{id:l}),b=h.length?await i(`MATCH (m:Media)-[h:HAS_EPISODE]->(e:Episode) WHERE m.uri IN $uris
1695
+ RETURN m.uri AS fromUri, e.uri AS toUri, h.claimer AS claimer, h.answerSeq AS answerSeq,
1696
+ h.key AS key
1697
+ ORDER BY fromUri, toUri, claimer`,{uris:h}):[],x=[...new Set([...b.map(e=>W(e.toUri)),...y.map(e=>W(e.episodeUri)).filter(Boolean)])].sort(),S=x.length?await i(`MATCH (m:Media)-[h:HAS_EPISODE]->(e:Episode)
1698
+ WHERE e.uri IN $uris AND NOT m.uri IN $members
1699
+ RETURN m.uri AS fromUri, e.uri AS toUri, h.claimer AS claimer, h.answerSeq AS answerSeq,
1700
+ h.key AS key
1701
+ ORDER BY fromUri, toUri, claimer`,{uris:x,members:h}):[],C=x.length?await i(`MATCH (a:Episode)-[l:EPISODE_LINK]->(b:Episode)
1702
+ WHERE a.uri IN $uris OR b.uri IN $uris
1703
+ RETURN a.uri AS fromUri, b.uri AS toUri, l.kind AS kind, l.status AS status, l.by AS by,
1704
+ l.reason AS reason, l.fromNumber AS fromNumber, l.toNumber AS toNumber,
1705
+ l.evidence AS evidence, l.supports AS supports, l.key AS key
1706
+ ORDER BY fromUri, toUri, by`,{uris:x}):[],w=x.length?await i(`MATCH (a:Episode)-[ec:EPISODE_CLAIMS]->(b:Episode)
1707
+ WHERE a.uri IN $uris OR b.uri IN $uris
1708
+ RETURN a.uri AS fromUri, b.uri AS toUri, ec.kind AS kind, ec.claimer AS claimer,
1709
+ ec.provenance AS provenance, ec.answerSeq AS answerSeq, ec.key AS key
1710
+ ORDER BY fromUri, toUri, claimer`,{uris:x}):[],ee=W(d?.aggUri),te=await i(`MATCH (k:Ask)
1711
+ RETURN k.clusterId AS clusterId, k.runUri AS runUri, k.origin AS origin, k.outcome AS outcome,
1712
+ k.reason AS reason, k.seq AS seq
1713
+ ORDER BY seq`),ne=new Set(h),re=te.filter(e=>{let n=W(e.clusterId);if(n===l||n===ee||n===t)return!0;let r=W(e.runUri);return r&&ne.has(r)?!0:rU(n).some(e=>ne.has(e))}),ie=[...new Set([...h,...x])],ae=ie.length?await i(`MATCH (a:Answer) WHERE a.uri IN $uris
1714
+ RETURN a.seq AS seq, a.uri AS uri, a.origin AS origin, a.operation AS operation, a.raw AS raw
1715
+ ORDER BY seq`,{uris:ie}):[],T=new Map;for(let e of y){let t=W(e.slotId),n=T.get(t)??{slotId:t,number:eZ(e.number),title:nZ(tZ(e.episode)?.titles),fills:[]},r=W(e.episodeUri);r&&n.fills.push({episodeUri:r,origin:W(e.origin),via:W(e.via),by:W(e.by),number:eZ(e.fillNumber),supports:QX(e.supports)}),T.set(t,n)}let E=tZ(d?.anomalies);return{asked:t,resolved:{clusterId:l,aggUri:ee,scope:W(d?.scope),kind:$X(d?.kind),otherClusters:u},members:m,claims:g.map(e=>({fromUri:W(e.fromUri),toUri:W(e.toUri),kind:W(e.kind),claimer:W(e.claimer),provenance:W(e.provenance),answerSeq:eZ(e.answerSeq)??0,targetScope:$X(e.targetScope),key:W(e.key)})),links:_.map(e=>({fromUri:W(e.fromUri),toUri:W(e.toUri),kind:W(e.kind),status:W(e.status),by:W(e.by),reason:W(e.reason),confidence:eZ(e.confidence),version:eZ(e.version),evidence:$X(e.evidence),gates:$X(e.gates),supports:QX(e.supports),key:W(e.key)})),attachments:v.map(e=>({runUri:W(e.fromUri)||W(e.fromId),containerUri:W(e.toUri)||W(e.toId),via:W(e.via),by:W(e.by),evidence:null,supports:QX(e.supports)})),episodes:[...T.values()].sort((e,t)=>(e.number===null)-+(t.number===null)||(e.number??0)-(t.number??0)||e.slotId.localeCompare(t.slotId)),episodeLinks:C.map(e=>({fromUri:W(e.fromUri),toUri:W(e.toUri),kind:W(e.kind),status:W(e.status),by:W(e.by),reason:W(e.reason),fromNumber:eZ(e.fromNumber),toNumber:eZ(e.toNumber),evidence:$X(e.evidence),supports:QX(e.supports),key:W(e.key)})),episodeClaims:w.map(e=>({fromUri:W(e.fromUri),toUri:W(e.toUri),kind:W(e.kind),claimer:W(e.claimer),provenance:W(e.provenance),answerSeq:eZ(e.answerSeq)??0,key:W(e.key)})),episodeSources:[...b,...S].map(e=>({fromUri:W(e.fromUri),toUri:W(e.toUri),claimer:W(e.claimer),answerSeq:eZ(e.answerSeq)??0,key:W(e.key)})),runLength:{value:eZ(d?.runLength),from:QX(d?.witnessedBy).join(`, `)||null,tier:eZ(d?.tier)===null?null:String(eZ(d?.tier)),witnesses:eZ(d?.witnesses)},anomalies:Array.isArray(E)?E.filter(e=>typeof e==`object`&&!!e).map(e=>({rule:W(e.rule),detail:W(e.detail)})):[],asks:re.map(e=>({seq:eZ(e.seq)??0,origin:W(e.origin),outcome:W(e.outcome),reason:$X(e.reason),at:null})),answers:ae.map(e=>({seq:eZ(e.seq)??0,uri:W(e.uri),origin:W(e.origin),operation:W(e.operation),bytes:iZ(e.raw)})),counts:c,cost:o()}},fZ=async e=>{if(!zV()||!Number.isSafeInteger(e))return null;let{query:t}=await rH(),{read:n}=aZ(t),[r]=await n(`MATCH (a:Answer) WHERE a.seq = cast($seq AS INT64)
1716
+ RETURN a.key AS key, a.seq AS seq, a.uri AS uri, a.origin AS origin, a.kind AS kind,
1717
+ a.operation AS operation, a.selection AS selection, a.raw AS raw`,{seq:String(e)});return r?{key:W(r.key),seq:eZ(r.seq)??e,uri:W(r.uri),origin:W(r.origin),kind:W(r.kind),operation:W(r.operation),selection:QX(r.selection),raw:W(r.raw)}:null};let pZ;const mZ=async e=>{let t=performance.now();uH(GW);let n=await rH(),r=await XX();if(console.info(`graph: engine ready in ${Math.round(performance.now()-t)} ms, version ${n.version}, ${QV.length} tables, ${r} origins`),e){WX();try{let e=await KX(`boot`);console.info(`graph: boot pass in ${e.ms} ms, ${e.iterations} iterations, ${e.changes.length} changes`)}catch(e){console.error(Error(`graph: the boot pass failed`,{cause:e}))}}},hZ=(e,t={})=>(RV(e),zV()?pZ??=mZ(t.scheduler===!0):Promise.resolve());function gZ(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var _Z=gZ();function vZ(e){_Z=e}var yZ={exec:()=>null};function bZ(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(SZ.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var xZ=(()=>{try{return!0}catch{return!1}})(),SZ={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`),blockquoteBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}>`)},CZ=/^(?:[ \t]*(?:\n|$))+/,wZ=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,TZ=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,EZ=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,DZ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,OZ=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,kZ=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,AZ=bZ(kZ).replace(/bull/g,OZ).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),jZ=bZ(kZ).replace(/bull/g,OZ).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),MZ=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,NZ=/^[^\n]+/,PZ=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,FZ=bZ(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,PZ).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),IZ=bZ(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,OZ).getRegex(),LZ=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,RZ=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,zZ=bZ(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,RZ).replace(`tag`,LZ).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),BZ=bZ(MZ).replace(`hr`,EZ).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,LZ).getRegex(),VZ={blockquote:bZ(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,BZ).getRegex(),code:wZ,def:FZ,fences:TZ,heading:DZ,hr:EZ,html:zZ,lheading:AZ,list:IZ,newline:CZ,paragraph:BZ,table:yZ,text:NZ},HZ=bZ(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,EZ).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,LZ).getRegex(),UZ={...VZ,lheading:jZ,table:HZ,paragraph:bZ(MZ).replace(`hr`,EZ).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,HZ).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,LZ).getRegex()},WZ={...VZ,html:bZ(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,RZ).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:yZ,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:bZ(MZ).replace(`hr`,EZ).replace(`heading`,` *#{1,6} *[^
1718
+ ]`).replace(`lheading`,AZ).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},GZ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,KZ=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,qZ=/^( {2,}|\\)\n(?!\s*$)/,JZ=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,YZ=/[\p{P}\p{S}]/u,XZ=/[\s\p{P}\p{S}]/u,ZZ=/[^\s\p{P}\p{S}]/u,QZ=bZ(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,XZ).getRegex(),$Z=/(?!~)[\p{P}\p{S}]/u,eQ=/(?!~)[\s\p{P}\p{S}]/u,tQ=/(?:[^\s\p{P}\p{S}]|~)/u,nQ=bZ(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,xZ?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),rQ=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,iQ=bZ(rQ,`u`).replace(/punct/g,YZ).getRegex(),aQ=bZ(rQ,`u`).replace(/punct/g,$Z).getRegex(),oQ=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,sQ=bZ(oQ,`gu`).replace(/notPunctSpace/g,ZZ).replace(/punctSpace/g,XZ).replace(/punct/g,YZ).getRegex(),cQ=bZ(oQ,`gu`).replace(/notPunctSpace/g,tQ).replace(/punctSpace/g,eQ).replace(/punct/g,$Z).getRegex(),lQ=bZ(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ZZ).replace(/punctSpace/g,XZ).replace(/punct/g,YZ).getRegex(),uQ=bZ(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,YZ).getRegex(),dQ=bZ(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ZZ).replace(/punctSpace/g,XZ).replace(/punct/g,YZ).getRegex(),fQ=bZ(/\\(punct)/,`gu`).replace(/punct/g,YZ).getRegex(),pQ=bZ(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),mQ=bZ(RZ).replace(`(?:-->|$)`,`-->`).getRegex(),hQ=bZ(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,mQ).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),gQ=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,_Q=bZ(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,gQ).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),vQ=bZ(/^!?\[(label)\]\[(ref)\]/).replace(`label`,gQ).replace(`ref`,PZ).getRegex(),yQ=bZ(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,PZ).getRegex(),bQ=bZ(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,vQ).replace(`nolink`,yQ).getRegex(),xQ=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,SQ={_backpedal:yZ,anyPunctuation:fQ,autolink:pQ,blockSkip:nQ,br:qZ,code:KZ,del:yZ,delLDelim:yZ,delRDelim:yZ,emStrongLDelim:iQ,emStrongRDelimAst:sQ,emStrongRDelimUnd:lQ,escape:GZ,link:_Q,nolink:yQ,punctuation:QZ,reflink:vQ,reflinkSearch:bQ,tag:hQ,text:JZ,url:yZ},CQ={...SQ,link:bZ(/^!?\[(label)\]\((.*?)\)/).replace(`label`,gQ).getRegex(),reflink:bZ(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,gQ).getRegex()},wQ={...SQ,emStrongRDelimAst:cQ,emStrongLDelim:aQ,delLDelim:uQ,delRDelim:dQ,url:bZ(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,xQ).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:bZ(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,xQ).getRegex()},TQ={...wQ,br:bZ(qZ).replace(`{2,}`,`*`).getRegex(),text:bZ(wQ.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},EQ={normal:VZ,gfm:UZ,pedantic:WZ},DQ={normal:SQ,gfm:wQ,breaks:TQ,pedantic:CQ},OQ={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},kQ=e=>OQ[e];function AQ(e,t){if(t){if(SZ.escapeTest.test(e))return e.replace(SZ.escapeReplace,kQ)}else if(SZ.escapeTestNoEncode.test(e))return e.replace(SZ.escapeReplaceNoEncode,kQ);return e}function jQ(e){try{e=encodeURI(e).replace(SZ.percentDecode,`%`)}catch{return null}return e}function MQ(e,t){let n=e.replace(SZ.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(SZ.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(SZ.slashPipe,`|`);return n}function NQ(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function PQ(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function FQ(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function IQ(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function LQ(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
1719
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
1720
+ `)}var RQ=class{options;rules;lexer;constructor(e){this.options=e||_Z}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:NQ(e,`
1721
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=LQ(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=NQ(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:NQ(t[0],`
1722
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=NQ(t[0],`
1723
+ `).split(`
1724
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
1725
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
1726
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
1727
+ ${s}`:s,r=r?`${r}
1728
+ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
1729
+ `+e.join(`
1730
+ `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
1731
+ `+e.join(`
1732
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
1733
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=FQ(t[2].split(`
1734
+ `,1)[0],t[1].length),l=e.split(`
1735
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
1736
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
1737
+ `,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
1738
+ `+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
1739
+ `+l}u=!l.trim(),r+=p+`
1740
+ `,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,``),e.tokens[0]?.type===`text`||e.tokens[0]?.type===`paragraph`){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,``),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:`checkbox`,raw:t[0]+` `,checked:t[0]!==`[ ]`};e.checked=n.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:`paragraph`,raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=MQ(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
1741
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(MQ(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
1742
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=NQ(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=PQ(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),IQ(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return IQ(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},zQ=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||_Z,this.options.tokenizer=this.options.tokenizer||new RQ,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:SZ,block:EQ.normal,inline:DQ.normal};this.options.pedantic?(t.block=EQ.pedantic,t.inline=DQ.pedantic):this.options.gfm&&(t.block=EQ.gfm,this.options.breaks?t.inline=DQ.breaks:t.inline=DQ.gfm),this.tokenizer.rules=t}static get rules(){return{block:EQ,inline:DQ}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(SZ.carriageReturn,`
1743
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(SZ.tabCharGlobal,` `).replace(SZ.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
1744
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
1745
+ `)?``:`
1746
+ `)+r.raw,n.text+=`
1747
+ `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
1748
+ `)?``:`
1749
+ `)+r.raw,n.text+=`
1750
+ `+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=(a.raw.endsWith(`
1751
+ `)?``:`
1752
+ `)+r.raw,a.text+=`
1753
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
1754
+ `)?``:`
1755
+ `)+r.raw,n.text+=`
1756
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``;for(;e;){a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},BQ=class{options;parser;constructor(e){this.options=e||_Z}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(SZ.notSpaceStart)?.[0],i=e.replace(SZ.endingNewline,``)+`
1757
+ `;return r?`<pre><code class="language-`+AQ(r)+`">`+(n?i:AQ(i,!0))+`</code></pre>
1758
+ `:`<pre><code>`+(n?i:AQ(i,!0))+`</code></pre>
1759
+ `}blockquote({tokens:e}){return`<blockquote>
1760
+ ${this.parser.parse(e)}</blockquote>
1761
+ `}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
1762
+ `}hr(e){return`<hr>
1763
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
1764
+ `+r+`</`+i+`>
1765
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
1766
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
1767
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
1768
+ <thead>
1769
+ `+t+`</thead>
1770
+ `+r+`</table>
1771
+ `}tablerow({text:e}){return`<tr>
1772
+ ${e}</tr>
1773
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
1774
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${AQ(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=jQ(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+AQ(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=jQ(e);if(i===null)return AQ(n);e=i;let a=`<img src="${e}" alt="${AQ(n)}"`;return t&&(a+=` title="${AQ(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:AQ(e.text)}},VQ=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},HQ=class e{options;renderer;textRenderer;constructor(e){this.options=e||_Z,this.options.renderer=this.options.renderer||new BQ,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new VQ}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},UQ=class{options;block;constructor(e){this.options=e||_Z}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?zQ.lex:zQ.lexInline}provideParser(){return this.block?HQ.parse:HQ.parseInline}},WQ=new class{defaults=gZ();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=HQ;Renderer=BQ;TextRenderer=VQ;Lexer=zQ;Tokenizer=RQ;Hooks=UQ;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new BQ(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new RQ(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new UQ;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];UQ.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&UQ.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return zQ.lex(e,t??this.defaults)}parser(e,t){return HQ.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?zQ.lex:zQ.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?HQ.parse:HQ.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?zQ.lex:zQ.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?HQ.parse:HQ.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
1775
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+AQ(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function GQ(e,t){return WQ.parse(e,t)}GQ.options=GQ.setOptions=function(e){return WQ.setOptions(e),GQ.defaults=WQ.defaults,vZ(GQ.defaults),GQ},GQ.getDefaults=gZ,GQ.defaults=_Z,GQ.use=function(...e){return WQ.use(...e),GQ.defaults=WQ.defaults,vZ(GQ.defaults),GQ},GQ.walkTokens=function(e,t){return WQ.walkTokens(e,t)},GQ.parseInline=WQ.parseInline,GQ.Parser=HQ,GQ.parser=HQ.parse,GQ.Renderer=BQ,GQ.TextRenderer=VQ,GQ.Lexer=zQ,GQ.lexer=zQ.lex,GQ.Tokenizer=RQ,GQ.Hooks=UQ,GQ.parse=GQ,GQ.options,GQ.setOptions,GQ.use,GQ.walkTokens,GQ.parseInline,HQ.parse,zQ.lex;
1776
+ /*! @license DOMPurify 3.4.13 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.13/LICENSE */
1777
+ function KQ(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function qQ(e){if(Array.isArray(e))return e}function JQ(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function YQ(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1778
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function XQ(e,t){return qQ(e)||JQ(e,t)||ZQ(e,t)||YQ()}function ZQ(e,t){if(e){if(typeof e==`string`)return KQ(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?KQ(e,t):void 0}}const QQ=Object.entries,$Q=Object.setPrototypeOf,e$=Object.isFrozen,t$=Object.getPrototypeOf,n$=Object.getOwnPropertyDescriptor;let r$=Object.freeze,i$=Object.seal,a$=Object.create,o$=typeof Reflect<`u`&&Reflect,s$=o$.apply,c$=o$.construct;r$||=function(e){return e},i$||=function(e){return e},s$||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},c$||=function(e){return new e(...[...arguments].slice(1))};const l$=k$(Array.prototype.forEach),u$=k$(Array.prototype.lastIndexOf),d$=k$(Array.prototype.pop),f$=k$(Array.prototype.push),p$=k$(Array.prototype.splice),m$=Array.isArray,h$=k$(String.prototype.toLowerCase),g$=k$(String.prototype.toString),_$=k$(String.prototype.match),v$=k$(String.prototype.replace),y$=k$(String.prototype.indexOf),b$=k$(String.prototype.trim),x$=k$(Number.prototype.toString),S$=k$(Boolean.prototype.toString),C$=typeof BigInt>`u`?null:k$(BigInt.prototype.toString),w$=typeof Symbol>`u`?null:k$(Symbol.prototype.toString),T$=k$(Object.prototype.hasOwnProperty),E$=k$(Object.prototype.toString),D$=k$(RegExp.prototype.test),O$=A$(TypeError);function k$(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return s$(e,t,n)}}function A$(e){return function(){return c$(e,[...arguments])}}function j$(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:h$;if($Q&&$Q(e,null),!m$(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(e$(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M$(e){for(let t=0;t<e.length;t++)T$(e,t)||(e[t]=null);return e}function N$(e){let t=a$(null);for(let r of QQ(e)){var n=XQ(r,2);let i=n[0],a=n[1];T$(e,i)&&(m$(a)?t[i]=M$(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=N$(a):t[i]=a)}return t}function P$(e){switch(typeof e){case`string`:return e;case`number`:return x$(e);case`boolean`:return S$(e);case`bigint`:return C$?C$(e):`0`;case`symbol`:return w$?w$(e):`Symbol()`;case`undefined`:return E$(e);case`function`:case`object`:{if(e===null)return E$(e);let t=e,n=F$(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:E$(e)}return E$(e)}default:return E$(e)}}function F$(e,t){for(;e!==null;){let n=n$(e,t);if(n){if(n.get)return k$(n.get);if(typeof n.value==`function`)return k$(n.value)}e=t$(e)}function n(){return null}return n}function I$(e){try{return D$(e,``),!0}catch{return!1}}const L$=r$(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),R$=r$(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),z$=r$([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),B$=r$([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),V$=r$(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),H$=r$([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),U$=r$([`#text`]),W$=r$(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),G$=r$(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),K$=r$(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),q$=r$([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),J$=i$(/{{[\w\W]*|^[\w\W]*}}/g),Y$=i$(/<%[\w\W]*|^[\w\W]*%>/g),X$=i$(/\${[\w\W]*/g),Z$=i$(/^data-[\-\w.\u00B7-\uFFFF]+$/),Q$=i$(/^aria-[\-\w]+$/),$$=i$(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),e1=i$(/^(?:\w+script|data):/i),t1=i$(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),n1=i$(/^html$/i),r1=i$(/^[a-z][.\w]*(-[.\w]+)+$/i),i1=i$(/<[/\w!]/g),a1=i$(/<[/\w]/g),o1=i$(/<\/no(script|embed|frames)/i),s1=i$(/\/>/i),c1={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},l1=function(){return typeof window>`u`?null:window},u1=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},d1=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},f1=function(e,t,n,r){return T$(e,t)&&m$(e[t])?j$(r.base?N$(r.base):{},e[t],r.transform):n};function p1(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:l1(),t=e=>p1(e);if(t.version=`3.4.13`,t.removed=[],!e||!e.document||e.document.nodeType!==c1.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=F$(d,`cloneNode`),p=F$(d,`remove`),m=F$(d,`nextSibling`),h=F$(d,`childNodes`),g=F$(d,`parentNode`),_=F$(d,`shadowRoot`),v=F$(d,`attributes`),y=o&&o.prototype?F$(o.prototype,`nodeType`):null,b=o&&o.prototype?F$(o.prototype,`nodeName`):null,x=o&&o.prototype?F$(o.prototype,`ownerDocument`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let S,C=``,w,ee=!1,te=0,ne=function(){if(te>0)throw O$(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},re=function(e){ne(),te++;try{return S.createHTML(e)}finally{te--}},ie=function(e){ne(),te++;try{return S.createScriptURL(e)}finally{te--}},ae=function(){return ee||=(w=u1(u,i),!0),w},T=n,E=T.implementation,oe=T.createNodeIterator,se=T.createDocumentFragment,ce=T.getElementsByTagName,le=r.importNode,ue=d1();t.isSupported=typeof QQ==`function`&&typeof g==`function`&&E&&E.createHTMLDocument!==void 0;let de=J$,fe=Y$,pe=X$,D=Z$,me=Q$,he=e1,ge=t1,_e=r1,ve=$$,ye=null,be=j$({},[...L$,...R$,...z$,...V$,...U$]),O=null,xe=j$({},[...W$,...G$,...K$,...q$]),Se=Object.seal(a$(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ce=null,we=null,Te=Object.seal(a$(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ee=!0,De=!0,Oe=!1,ke=!0,Ae=!1,je=!0,Me=!1,k=!1,Ne=null,Pe=null,Fe=!1,Ie=!1,Le=!1,Re=!1,ze=!0,Be=!1,Ve=`user-content-`,He=!0,Ue=!1,We={},Ge=null,Ke=j$({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),qe=null,Je=j$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ye=null,Xe=j$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ze=`http://www.w3.org/1998/Math/MathML`,Qe=`http://www.w3.org/2000/svg`,$e=`http://www.w3.org/1999/xhtml`,et=$e,tt=!1,nt=null,rt=j$({},[Ze,Qe,$e],g$),it=r$([`mi`,`mo`,`mn`,`ms`,`mtext`]),at=j$({},it),ot=r$([`annotation-xml`]),st=j$({},ot),ct=j$({},[`title`,`style`,`font`,`a`,`script`]),lt=null,ut=[`application/xhtml+xml`,`text/html`],dt=null,ft=null,pt=n.createElement(`form`),A=function(e){return e instanceof RegExp||e instanceof Function},mt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ft&&ft===e)return;(!e||typeof e!=`object`)&&(e={}),e=N$(e),lt=ut.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,dt=lt===`application/xhtml+xml`?g$:h$,ye=f1(e,`ALLOWED_TAGS`,be,{transform:dt}),O=f1(e,`ALLOWED_ATTR`,xe,{transform:dt}),nt=f1(e,`ALLOWED_NAMESPACES`,rt,{transform:g$}),Ye=f1(e,`ADD_URI_SAFE_ATTR`,Xe,{transform:dt,base:Xe}),qe=f1(e,`ADD_DATA_URI_TAGS`,Je,{transform:dt,base:Je}),Ge=f1(e,`FORBID_CONTENTS`,Ke,{transform:dt}),Ce=f1(e,`FORBID_TAGS`,N$({}),{transform:dt}),we=f1(e,`FORBID_ATTR`,N$({}),{transform:dt}),We=T$(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?N$(e.USE_PROFILES):e.USE_PROFILES:!1,Ee=e.ALLOW_ARIA_ATTR!==!1,De=e.ALLOW_DATA_ATTR!==!1,Oe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ke=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ae=e.SAFE_FOR_TEMPLATES||!1,je=e.SAFE_FOR_XML!==!1,Me=e.WHOLE_DOCUMENT||!1,Ie=e.RETURN_DOM||!1,Le=e.RETURN_DOM_FRAGMENT||!1,Re=e.RETURN_TRUSTED_TYPE||!1,Fe=e.FORCE_BODY||!1,ze=e.SANITIZE_DOM!==!1,Be=e.SANITIZE_NAMED_PROPS||!1,He=e.KEEP_CONTENT!==!1,Ue=e.IN_PLACE||!1,ve=I$(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:$$,et=typeof e.NAMESPACE==`string`?e.NAMESPACE:$e,at=T$(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?N$(e.MATHML_TEXT_INTEGRATION_POINTS):j$({},it),st=T$(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?N$(e.HTML_INTEGRATION_POINTS):j$({},ot);let t=T$(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?N$(e.CUSTOM_ELEMENT_HANDLING):a$(null);if(Se=a$(null),T$(t,`tagNameCheck`)&&A(t.tagNameCheck)&&(Se.tagNameCheck=t.tagNameCheck),T$(t,`attributeNameCheck`)&&A(t.attributeNameCheck)&&(Se.attributeNameCheck=t.attributeNameCheck),T$(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Se.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),i$(Se),Ae&&(De=!1),Le&&(Ie=!0),We&&(ye=j$({},U$),O=a$(null),We.html===!0&&(j$(ye,L$),j$(O,W$)),We.svg===!0&&(j$(ye,R$),j$(O,G$),j$(O,q$)),We.svgFilters===!0&&(j$(ye,z$),j$(O,G$),j$(O,q$)),We.mathMl===!0&&(j$(ye,V$),j$(O,K$),j$(O,q$))),Te.tagCheck=null,Te.attributeCheck=null,T$(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Te.tagCheck=e.ADD_TAGS:m$(e.ADD_TAGS)&&(ye===be&&(ye=N$(ye)),j$(ye,e.ADD_TAGS,dt))),T$(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Te.attributeCheck=e.ADD_ATTR:m$(e.ADD_ATTR)&&(O===xe&&(O=N$(O)),j$(O,e.ADD_ATTR,dt))),T$(e,`ADD_URI_SAFE_ATTR`)&&m$(e.ADD_URI_SAFE_ATTR)&&j$(Ye,e.ADD_URI_SAFE_ATTR,dt),T$(e,`FORBID_CONTENTS`)&&m$(e.FORBID_CONTENTS)&&(Ge===Ke&&(Ge=N$(Ge)),j$(Ge,e.FORBID_CONTENTS,dt)),T$(e,`ADD_FORBID_CONTENTS`)&&m$(e.ADD_FORBID_CONTENTS)&&(Ge===Ke&&(Ge=N$(Ge)),j$(Ge,e.ADD_FORBID_CONTENTS,dt)),He&&(ye[`#text`]=!0),Me&&j$(ye,[`html`,`head`,`body`]),ye.table&&(j$(ye,[`tbody`]),delete Ce.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw O$(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw O$(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=S;S=e.TRUSTED_TYPES_POLICY;try{C=re(``)}catch(e){throw S=t,e}}else e.TRUSTED_TYPES_POLICY===null?(S=void 0,C=``):(S===void 0&&(S=ae()),S&&typeof C==`string`&&(C=re(``)));r$&&r$(e),ft=e},ht=j$({},[...R$,...z$,...B$]),gt=j$({},[...V$,...H$]),_t=function(e,t,n){return t.namespaceURI===$e?e===`svg`:t.namespaceURI===Ze?e===`svg`&&(n===`annotation-xml`||at[n]):!!ht[e]},vt=function(e,t,n){return t.namespaceURI===$e?e===`math`:t.namespaceURI===Qe?e===`math`&&st[n]:!!gt[e]},yt=function(e,t,n){return t.namespaceURI===Qe&&!st[n]||t.namespaceURI===Ze&&!at[n]?!1:!gt[e]&&(ct[e]||!ht[e])},bt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:et,tagName:`template`});let n=h$(e.tagName),r=h$(t.tagName);return nt[e.namespaceURI]?e.namespaceURI===Qe?_t(n,t,r):e.namespaceURI===Ze?vt(n,t,r):e.namespaceURI===$e?yt(n,t,r):!!(lt===`application/xhtml+xml`&&nt[e.namespaceURI]):!1},xt=function(e){f$(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw O$(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},St=function(e){wt(e);let t=h(e);if(t){let e=[];l$(t,t=>{f$(e,t)}),l$(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},j=function(e,n){try{f$(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{f$(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ie||Le)try{xt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Ct=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||O[dt(i)]))try{e.removeAttribute(i)}catch{}}},wt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===c1.element&&Ct(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Tt=function(e){if(!je)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===c1.processingInstruction||n===c1.comment&&D$(a1,e.data)){try{p(e)}catch{}continue}if(n===c1.element){let t=e,n=dt(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Et=function(e){let t=null,r=null;if(Fe)e=`<remove></remove>`+e;else{let t=_$(e,/^[\r\n\t ]+/);r=t&&t[0]}lt===`application/xhtml+xml`&&et===$e&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=S?re(e):e;if(et===$e)try{t=new l().parseFromString(i,lt)}catch{}if(!t||!t.documentElement){t=E.createDocument(et,`template`,null);try{t.documentElement.innerHTML=tt?C:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),et===$e?ce.call(t,Me?`html`:`body`)[0]:Me?t.documentElement:a},Dt=function(e){let t=x?x(e):e.ownerDocument;return oe.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},M=function(e){return e=v$(e,de,` `),e=v$(e,fe,` `),e=v$(e,pe,` `),e},Ot=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=oe.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=M(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&l$(i,e=>{At(e.content)&&Ot(e.content)})},kt=function(e){let t=b?b(e):null;return typeof t!=`string`||dt(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},At=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===c1.documentFragment}catch{return!1}},jt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Mt(e,n,r){e.length!==0&&l$(e,e=>{e.call(t,n,r,ft)})}let Nt=function(e,t){return!!(je&&e.hasChildNodes()&&!jt(e.firstElementChild)&&D$(i1,e.textContent)&&D$(i1,e.innerHTML)||je&&e.namespaceURI===$e&&t===`style`&&jt(e.firstElementChild)||e.nodeType===c1.processingInstruction||je&&e.nodeType===c1.comment&&D$(a1,e.data))},N=function(e,t,n){if(!Ce[t]&&Rt(t)&&(Se.tagNameCheck instanceof RegExp&&D$(Se.tagNameCheck,t)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(t)))return!1;if(He&&!Ge[t]){let t=g(e),r=h(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,m(e))}}}return xt(e),!0},Pt=function(e,t,n,r){return e.length===0?t:t===n||t===r?N$(t):t},Ft=function(e,n){if(Mt(ue.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return Ue&&wt(e),!0;if(kt(e))return xt(e),!0;let r=dt(b?b(e):e.nodeName);if(ye=Pt(ue.uponSanitizeElement,ye,be,Ne),Mt(ue.uponSanitizeElement,e,{tagName:r,allowedTags:ye}),e!==n&&g(e)===null)return Ue&&wt(e),!0;if(Nt(e,r))return xt(e),!0;if(Ce[r]||!(Te.tagCheck instanceof Function&&Te.tagCheck(r))&&!ye[r]){let t=N(e,r,n);return t===!1&&Mt(ue.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===c1.element&&!bt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&D$(o1,e.innerHTML))return xt(e),!0;if(Ae&&e.nodeType===c1.text){let n=M(e.textContent);e.textContent!==n&&(f$(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Mt(ue.afterSanitizeElements,e,null),!1},It=function(e,t,r){if(we[t]||je&&t===`patchsrc`||je&&t===`for`&&e!==`label`&&e!==`output`||ze&&(t===`id`||t===`name`)&&(r in n||r in pt))return!1;let i=O[t]||Te.attributeCheck instanceof Function&&Te.attributeCheck(t,e);if(!(De&&D$(D,t))&&!(Ee&&D$(me,t))){if(!i){if(!(Rt(e)&&(Se.tagNameCheck instanceof RegExp&&D$(Se.tagNameCheck,e)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(e))&&(Se.attributeNameCheck instanceof RegExp&&D$(Se.attributeNameCheck,t)||Se.attributeNameCheck instanceof Function&&Se.attributeNameCheck(t,e))||t===`is`&&Se.allowCustomizedBuiltInElements&&(Se.tagNameCheck instanceof RegExp&&D$(Se.tagNameCheck,r)||Se.tagNameCheck instanceof Function&&Se.tagNameCheck(r))))return!1}else if(!Ye[t]&&!D$(ve,v$(r,ge,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&y$(r,`data:`)===0&&qe[e])&&!(Oe&&!D$(he,v$(r,ge,``)))&&r)return!1}return!0},Lt=j$({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Rt=function(e){return!Lt[h$(e)]&&D$(_e,e)},zt=function(e,t,n,r){if(S&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return re(r);case`TrustedScriptURL`:return ie(r)}return r},Bt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),kt(e)?xt(e):d$(t.removed)}catch{j(n,e)}},Vt=function(e){Mt(ue.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||kt(e))return;O=Pt(ue.uponSanitizeAttribute,O,xe,Pe);let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:O,forceKeepAttr:void 0},r=t.length,i=dt(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=dt(o),u=c,d=o===`value`?u:b$(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Mt(ue.uponSanitizeAttribute,e,n),d=n.attrValue,Be&&(l===`id`||l===`name`)&&y$(d,Ve)!==0&&(j(o,e),d=Ve+d),je&&D$(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){j(o,e);continue}if(l===`attributename`&&_$(d,`href`)){j(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){j(o,e);continue}if(!ke&&D$(s1,d)){j(o,e);continue}if(Ae&&(d=M(d)),!It(i,l,d)){j(o,e);continue}d=zt(i,l,s,d),d!==u&&Bt(e,o,s,d)}}Mt(ue.afterSanitizeAttributes,e,null)},Ht=function(e){let t=null,n=Dt(e);for(Mt(ue.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Mt(ue.uponSanitizeShadowNode,t,null),Ft(t,e),Vt(t),At(t.content)&&Ht(t.content),(y?y(t):t.nodeType)===c1.element){let e=_(t);At(e)&&(Ut(e),Ht(e))}Mt(ue.afterSanitizeShadowDOM,e,null)},Ut=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Ht(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===c1.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&dt(e)===`template`){let e=n.content;At(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);At(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(tt=!e,tt&&(e=`<!-->`),typeof e!=`string`&&!jt(e)&&(e=P$(e),typeof e!=`string`))throw O$(`dirty is not a string, aborting`);if(!t.isSupported)return e;k?(ye=Ne,O=Pe):mt(n),(ue.uponSanitizeElement.length>0||ue.uponSanitizeAttribute.length>0)&&(ye=N$(ye)),ue.uponSanitizeAttribute.length>0&&(O=N$(O)),t.removed=[];let c=Ue&&typeof e!=`string`&&jt(e);if(c){Tt(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=dt(t);if(!ye[n]||Ce[n])throw St(e),O$(`root node is forbidden and cannot be sanitized in-place`)}if(kt(e))throw St(e),O$(`root node is clobbered and cannot be sanitized in-place`);try{Ut(e)}catch(t){throw St(e),t}}else if(jt(e))i=Et(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===c1.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Ut(a);else{if(!Ie&&!Ae&&!Me&&e.indexOf(`<`)===-1)return S&&Re?re(e):e;if(i=Et(e),!i)return Ie?null:Re?C:``}i&&Fe&&xt(i.firstChild);let l=c?e:i;try{let e=Dt(l);for(;o=e.nextNode();)Ft(o,l),Vt(o),At(o.content)&&Ht(o.content)}catch(n){throw c&&(St(e),l$(t.removed,e=>{e.element&&wt(e.element)})),n}if(c)return l$(t.removed,e=>{e.element&&wt(e.element)}),Ae&&Ot(e),e;if(Ie){if(Ae&&Ot(i),Le)for(s=se.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(O.shadowroot||O.shadowrootmode)&&(s=le.call(r,s,!0)),s}let u=Me?i.outerHTML:i.innerHTML;return Me&&ye[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&D$(n1,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
1779
+ `+u),Ae&&(u=M(u)),S&&Re?re(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};mt(e),k=!0,Ne=ye,Pe=O},t.clearConfig=function(){ft=null,k=!1,Ne=null,Pe=null,S=w,C=``},t.isValidAttribute=function(e,t,n){ft||mt({});let r=dt(e),i=dt(t);return It(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&T$(ue,e)&&f$(ue[e],t)},t.removeHook=function(e,t){if(T$(ue,e)){if(t!==void 0){let n=u$(ue[e],t);return n===-1?void 0:p$(ue[e],n,1)[0]}return d$(ue[e])}},t.removeHooks=function(e){T$(ue,e)&&(ue[e]=[])},t.removeAllHooks=function(){ue=d1()},t}var m1=p1();const h1=Symbol(`changed`),g1=Symbol(`classList`),_1=Symbol(`CustomElements`),v1=Symbol(`content`),y1=Symbol(`dataset`),b1=Symbol(`doctype`),x1=Symbol(`DOMParser`),G=Symbol(`end`),S1=Symbol(`EventTarget`),C1=Symbol(`globals`),w1=Symbol(`image`),T1=Symbol(`mime`),E1=Symbol(`MutationObserver`),K=Symbol(`next`),D1=Symbol(`ownerElement`),O1=Symbol(`prev`),k1=Symbol(`private`),A1=Symbol(`sheet`),j1=Symbol(`start`),M1=Symbol(`style`),N1=Symbol(`upgrade`),P1=Symbol(`value`),F1=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),I1=String.fromCodePoint??(e=>{let t=``;return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t});function L1(e){return e>=55296&&e<=57343||e>1114111?65533:F1.get(e)??e}function R1(e){let t=typeof atob==`function`?atob(e):typeof Buffer.from==`function`?Buffer.from(e,`base64`).toString(`binary`):new Buffer(e,`base64`).toString(`binary`),n=t.length&-2,r=new Uint16Array(n/2);for(let e=0,i=0;e<n;e+=2){let n=t.charCodeAt(e),a=t.charCodeAt(e+1);r[i++]=n|a<<8}return r}const z1=R1(`QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4DAAMBA8CFoYZFj4SFjcgBhZAAAoFMqAAFncIsAjgBvAG4ABGFmAADgNdg43fAlbHlGdW5jdGlvbgCgYSBpAG4AZwA7gMUAxUAAAWNzpACoAHIAAOA12Jzc6SFnbgCgVCJpAGwAZABlADuAwwDDQG0AbAA7gMQAxEAABGFjZWZvcnN1xQDYANoA7QDxAPYA+QD8AAABY3LJAM8AayNzbGFzaAAAoBYidgHTANUAAKDnKmUAZAAAoAYjeQARZIABY3J0AOAA5QDrAGEidXNlAACgNSLuI291bGxpcwCgLCFhAJJjcgAA4DXYBd1wAGYAAOA12Dnd5SF2ZdhiYwDyAOoAbSJwZXEAAKBOIgAHSE9hY2RlZmhpbG9yc3UXARoBHwE6AVIBVQFiAWQBZgGCAakB6QHtAfIBYwB5ACdkUABZADuAqQCpQIABY3B5ACUBKAE1AfUhdGUGYWmg0iJ0KGFsRGlmZmVyZW50aWFsRAAAoEUhbCJleXMAAKAtIQACYWVpb0EBRAFKAU0B8iFvbgxhZABpAGwAO4DHAMdAcgBjAAhhbiJpbnQAAKAwIm8AdAAKYQABZG5ZAV0BaSJsbGEAuGB0I2VyRG90ALdg8gA5AWkAp2NyImNsZQAAAkRNUFRwAXQBeQF9AW8AdAAAoJkiaSJudXMAAKCWIuwhdXMAoJUiaSJtZXMAAKCXIm8AAAFjc4cBlAFrKndpc2VDb250b3VySW50ZWdyYWwAAKAyImUjQ3VybHkAAAFEUZwBpAFvJXVibGVRdW90ZQAAoB0gdSJvdGUAAKAZIAACbG5wdbABtgHNAdgBbwBuAGWgNyIAoHQqgAFnaXQAvAHBAcUB8iJ1ZW50AKBhIm4AdAAAoC8i7yV1ckludGVncmFsAKAuIgABZnLRAdMBAKACIe8iZHVjdACgECJuLnRlckNsb2Nrd2lzZUNvbnRvdXJJbnRlZ3JhbAAAoDMi7yFzcwCgLypjAHIAAOA12J7ccABDoNMiYQBwAACgTSKABURKU1phY2VmaW9zAAsCEgIVAhgCGwIsAjQCOQI9AnMCfwNvoEUh9CJyYWhkAKARKWMAeQACZGMAeQAFZGMAeQAPZIABZ3JzACECJQIoAuchZXIAoCEgcgAAoKEhaAB2AACg5CoAAWF5MAIzAvIhb24OYRRkbAB0oAciYQCUY3IAAOA12AfdAAFhZkECawIAAWNtRQJnAvIjaXRpY2FsAAJBREdUUAJUAl8CYwJjInV0ZQC0YG8AdAFZAloC2WJiJGxlQWN1dGUA3WJyImF2ZQBgYGkibGRlANxi7yFuZACgxCJmJWVyZW50aWFsRAAAoEYhcAR9AgAAAAAAAIECjgIAABoDZgAA4DXYO91EoagAhQKJAm8AdAAAoNwgcSJ1YWwAAKBQIuIhbGUAA0NETFJVVpkCqAK1Au8C/wIRA28AbgB0AG8AdQByAEkAbgB0AGUAZwByAGEA7ADEAW8AdAKvAgAAAACwAqhgbiNBcnJvdwAAoNMhAAFlb7kC0AJmAHQAgAFBUlQAwQLGAs0CciJyb3cAAKDQIekkZ2h0QXJyb3cAoNQhZQDlACsCbgBnAAABTFLWAugC5SFmdAABQVLcAuECciJyb3cAAKD4J+kkZ2h0QXJyb3cAoPon6SRnaHRBcnJvdwCg+SdpImdodAAAAUFU9gL7AnIicm93AACg0iFlAGUAAKCoInAAQQIGAwAAAAALA3Iicm93AACg0SFvJHduQXJyb3cAAKDVIWUlcnRpY2FsQmFyAACgJSJuAAADQUJMUlRhJAM2AzoDWgNxA3oDciJyb3cAAKGTIUJVLAMwA2EAcgAAoBMpcCNBcnJvdwAAoPUhciJldmUAEWPlIWZ00gJDAwAASwMAAFIDaSVnaHRWZWN0b3IAAKBQKWUkZVZlY3RvcgAAoF4p5SJjdG9yQqC9IWEAcgAAoFYpaSJnaHQA1AFiAwAAaQNlJGVWZWN0b3IAAKBfKeUiY3RvckKgwSFhAHIAAKBXKWUAZQBBoKQiciJyb3cAAKCnIXIAcgBvAPcAtAIAAWN0gwOHA3IAAOA12J/c8iFvaxBhAAhOVGFjZGZnbG1vcHFzdHV4owOlA6kDsAO/A8IDxgPNA9ID8gP9AwEEFAQeBCAEJQRHAEphSAA7gNAA0EBjAHUAdABlADuAyQDJQIABYWl5ALYDuQO+A/Ihb24aYXIAYwA7gMoAykAtZG8AdAAWYXIAAOA12AjdcgBhAHYAZQA7gMgAyEDlIm1lbnQAoAgiAAFhcNYD2QNjAHIAEmF0AHkAUwLhAwAAAADpA20lYWxsU3F1YXJlAACg+yVlJ3J5U21hbGxTcXVhcmUAAKCrJQABZ3D2A/kDbwBuABhhZgAA4DXYPN3zImlsb26VY3UAAAFhaQYEDgRsAFSgdSppImxkZQAAoEIi7CNpYnJpdW0AoMwhAAFjaRgEGwRyAACgMCFtAACgcyphAJdjbQBsADuAywDLQAABaXApBC0E8yF0cwCgAyLvJG5lbnRpYWxFAKBHIYACY2Zpb3MAPQQ/BEMEXQRyBHkAJGRyAADgNdgJ3WwibGVkAFMCTAQAAAAAVARtJWFsbFNxdWFyZQAAoPwlZSdyeVNtYWxsU3F1YXJlAACgqiVwA2UEAABpBAAAAABtBGYAAOA12D3dwSFsbACgACLyI2llcnRyZgCgMSFjAPIAcQQABkpUYWJjZGZnb3JzdIgEiwSOBJMElwSkBKcEqwStBLIE5QTqBGMAeQADZDuAPgA+QO0hbWFkoJMD3GNyImV2ZQAeYYABZWl5AJ0EoASjBOQhaWwiYXIAYwAcYRNkbwB0ACBhcgAA4DXYCt0AoNkicABmAADgNdg+3eUiYXRlcgADRUZHTFNUvwTIBM8E1QTZBOAEcSJ1YWwATKBlIuUhc3MAoNsidSRsbEVxdWFsAACgZyJyI2VhdGVyAACgoirlIXNzAKB3IuwkYW50RXF1YWwAoH4qaSJsZGUAAKBzImMAcgAA4DXYotwAoGsiAARBYWNmaW9zdfkE/QQFBQgFCwUTBSIFKwVSIkRjeQAqZAABY3QBBQQFZQBrAMdiXmDpIXJjJGFyAACgDCFsJWJlcnRTcGFjZQAAoAsh8AEYBQAAGwVmAACgDSHpJXpvbnRhbExpbmUAoAAlAAFjdCYFKAXyABIF8iFvayZhbQBwAEQBMQU5BW8AdwBuAEgAdQBtAPAAAAFxInVhbAAAoE8iAAdFSk9hY2RmZ21ub3N0dVMFVgVZBVwFYwVtBXAFcwV6BZAFtgXFBckFzQVjAHkAFWTsIWlnMmFjAHkAAWRjAHUAdABlADuAzQDNQAABaXlnBWwFcgBjADuAzgDOQBhkbwB0ADBhcgAAoBEhcgBhAHYAZQA7gMwAzEAAoREhYXB/BYsFAAFjZ4MFhQVyACphaSNuYXJ5SQAAoEghbABpAGUA8wD6AvQBlQUAAKUFZaAsIgABZ3KaBZ4F8iFhbACgKyLzI2VjdGlvbgCgwiJpI3NpYmxlAAABQ1SsBbEFbyJtbWEAAKBjIGkibWVzAACgYiCAAWdwdAC8Bb8FwwVvAG4ALmFmAADgNdhA3WEAmWNjAHIAAKAQIWkibGRlAChh6wHSBQAA1QVjAHkABmRsADuAzwDPQIACY2Zvc3UA4QXpBe0F8gX9BQABaXnlBegFcgBjADRhGWRyAADgNdgN3XAAZgAA4DXYQd3jAfcFAAD7BXIAAOA12KXc8iFjeQhk6yFjeQRkgANISmFjZm9zAAwGDwYSBhUGHQYhBiYGYwB5ACVkYwB5AAxk8CFwYZpjAAFleRkGHAbkIWlsNmEaZHIAAOA12A7dcABmAADgNdhC3WMAcgAA4DXYptyABUpUYWNlZmxtb3N0AD0GQAZDBl4GawZkB2gHcAd0B80H2gdjAHkACWQ7gDwAPECAAmNtbnByAEwGTwZSBlUGWwb1IXRlOWHiIWRhm2NnAACg6ifsI2FjZXRyZgCgEiFyAACgniGAAWFleQBkBmcGagbyIW9uPWHkIWlsO2EbZAABZnNvBjQHdAAABUFDREZSVFVWYXKABp4GpAbGBssG3AYDByEHwQIqBwABbnKEBowGZyVsZUJyYWNrZXQAAKDoJ/Ihb3cAoZAhQlKTBpcGYQByAACg5CHpJGdodEFycm93AKDGIWUjaWxpbmcAAKAII28A9QGqBgAAsgZiJWxlQnJhY2tldAAAoOYnbgDUAbcGAAC+BmUkZVZlY3RvcgAAoGEp5SJjdG9yQqDDIWEAcgAAoFkpbCJvb3IAAKAKI2kiZ2h0AAABQVbSBtcGciJyb3cAAKCUIeUiY3RvcgCgTikAAWVy4AbwBmUAAKGjIkFW5gbrBnIicm93AACgpCHlImN0b3IAoFopaSNhbmdsZQBCorIi+wYAAAAA/wZhAHIAAKDPKXEidWFsAACgtCJwAIABRFRWAAoHEQcYB+8kd25WZWN0b3IAoFEpZSRlVmVjdG9yAACgYCnlImN0b3JCoL8hYQByAACgWCnlImN0b3JCoLwhYQByAACgUilpAGcAaAB0AGEAcgByAG8A9wDMAnMAAANFRkdMU1Q/B0cHTgdUB1gHXwfxJXVhbEdyZWF0ZXIAoNoidSRsbEVxdWFsAACgZiJyI2VhdGVyAACgdiLlIXNzAKChKuwkYW50RXF1YWwAoH0qaSJsZGUAAKByInIAAOA12A/dZaDYIuYjdGFycm93AKDaIWkiZG90AD9hgAFucHcAege1B7kHZwAAAkxSbHKCB5QHmwerB+UhZnQAAUFSiAeNB3Iicm93AACg9SfpJGdodEFycm93AKD3J+kkZ2h0QXJyb3cAoPYn5SFmdAABYXLcAqEHaQBnAGgAdABhAHIAcgBvAPcA5wJpAGcAaAB0AGEAcgByAG8A9wDuAmYAAOA12EPdZQByAAABTFK/B8YHZSRmdEFycm93AACgmSHpJGdodEFycm93AKCYIYABY2h0ANMH1QfXB/IAWgYAoLAh8iFva0FhAKBqIgAEYWNlZmlvc3XpB+wH7gf/BwMICQgOCBEIcAAAoAUpeQAcZAABZGzyB/kHaSR1bVNwYWNlAACgXyBsI2ludHJmAACgMyFyAADgNdgQ3e4jdXNQbHVzAKATInAAZgAA4DXYRN1jAPIA/gecY4AESmFjZWZvc3R1ACEIJAgoCDUIgQiFCDsKQApHCmMAeQAKZGMidXRlAENhgAFhZXkALggxCDQI8iFvbkdh5CFpbEVhHWSAAWdzdwA7CGEIfQjhInRpdmWAAU1UVgBECEwIWQhlJWRpdW1TcGFjZQAAoAsgaABpAAABY25SCFMIawBTAHAAYQBjAOUASwhlAHIAeQBUAGgAaQDuAFQI9CFlZAABR0xnCHUIcgBlAGEAdABlAHIARwByAGUAYQB0AGUA8gDrBGUAcwBzAEwAZQBzAPMA2wdMImluZQAKYHIAAOA12BHdAAJCbnB0jAiRCJkInAhyImVhawAAoGAgwiZyZWFraW5nU3BhY2WgYGYAAKAVIUOq7CqzCMIIzQgAAOcIGwkAAAAAAAAtCQAAbwkAAIcJAACdCcAJGQoAADQKAAFvdbYIvAjuI2dydWVudACgYiJwIkNhcAAAoG0ibyh1YmxlVmVydGljYWxCYXIAAKAmIoABbHF4ANII1wjhCOUibWVudACgCSL1IWFsVKBgImkibGRlAADgQiI4A2kic3RzAACgBCJyI2VhdGVyAACjbyJFRkdMU1T1CPoIAgkJCQ0JFQlxInVhbAAAoHEidSRsbEVxdWFsAADgZyI4A3IjZWF0ZXIAAOBrIjgD5SFzcwCgeSLsJGFudEVxdWFsAOB+KjgDaSJsZGUAAKB1IvUhbXBEASAJJwnvI3duSHVtcADgTiI4A3EidWFsAADgTyI4A2UAAAFmczEJRgn0JFRyaWFuZ2xlQqLqIj0JAAAAAEIJYQByAADgzyk4A3EidWFsAACg7CJzAICibiJFR0xTVABRCVYJXAlhCWkJcSJ1YWwAAKBwInIjZWF0ZXIAAKB4IuUhc3MA4GoiOAPsJGFudEVxdWFsAOB9KjgDaSJsZGUAAKB0IuUic3RlZAABR0x1CX8J8iZlYXRlckdyZWF0ZXIA4KIqOAPlI3NzTGVzcwDgoSo4A/IjZWNlZGVzAKGAIkVTjwmVCXEidWFsAADgryo4A+wkYW50RXF1YWwAoOAiAAFlaaAJqQl2JmVyc2VFbGVtZW50AACgDCLnJWh0VHJpYW5nbGVCousitgkAAAAAuwlhAHIAAODQKTgDcSJ1YWwAAKDtIgABcXXDCeAJdSNhcmVTdQAAAWJwywnVCfMhZXRF4I8iOANxInVhbAAAoOIi5SJyc2V0ReCQIjgDcSJ1YWwAAKDjIoABYmNwAOYJ8AkNCvMhZXRF4IIi0iBxInVhbAAAoIgi4yJlZWRzgKGBIkVTVAD6CQAKBwpxInVhbAAA4LAqOAPsJGFudEVxdWFsAKDhImkibGRlAADgfyI4A+UicnNldEXggyLSIHEidWFsAACgiSJpImxkZQCAoUEiRUZUACIKJwouCnEidWFsAACgRCJ1JGxsRXF1YWwAAKBHImkibGRlAACgSSJlJXJ0aWNhbEJhcgAAoCQiYwByAADgNdip3GkAbABkAGUAO4DRANFAnWMAB0VhY2RmZ21vcHJzdHV2XgphCmgKcgp2CnoKgQqRCpYKqwqtCrsKyArNCuwhaWdSYWMAdQB0AGUAO4DTANNAAAFpeWwKcQpyAGMAO4DUANRAHmRiImxhYwBQYXIAAOA12BLdcgBhAHYAZQA7gNIA0kCAAWFlaQCHCooKjQpjAHIATGFnAGEAqWNjInJvbgCfY3AAZgAA4DXYRt3lI25DdXJseQABRFGeCqYKbyV1YmxlUXVvdGUAAKAcIHUib3RlAACgGCAAoFQqAAFjbLEKtQpyAADgNdiq3GEAcwBoADuA2ADYQGkAbAHACsUKZABlADuA1QDVQGUAcwAAoDcqbQBsADuA1gDWQGUAcgAAAUJQ0wrmCgABYXLXCtoKcgAAoD4gYQBjAAABZWvgCuIKAKDeI2UAdAAAoLQjYSVyZW50aGVzaXMAAKDcI4AEYWNmaGlsb3JzAP0KAwsFCwkLCwsMCxELIwtaC3IjdGlhbEQAAKACInkAH2RyAADgNdgT3WkApmOgY/Ujc01pbnVzsWAAAWlwFQsgC24AYwBhAHIAZQBwAGwAYQBuAOUACgVmAACgGSGAobsqZWlvACoLRQtJC+MiZWRlc4CheiJFU1QANAs5C0ALcSJ1YWwAAKCvKuwkYW50RXF1YWwAoHwiaSJsZGUAAKB+Im0AZQAAoDMgAAFkcE0LUQv1IWN0AKAPIm8jcnRpb24AYaA3ImwAAKAdIgABY2leC2ILcgAA4DXYq9yoYwACVWZvc2oLbwtzC3cLTwBUADuAIgAiQHIAAOA12BTdcABmAACgGiFjAHIAAOA12KzcAAZCRWFjZWZoaW9yc3WPC5MLlwupC7YL2AvbC90LhQyTDJoMowzhIXJyAKAQKUcAO4CuAK5AgAFjbnIAnQugC6ML9SF0ZVRhZwAAoOsncgB0oKAhbAAAoBYpgAFhZXkArwuyC7UL8iFvblhh5CFpbFZhIGR2oBwhZSJyc2UAAAFFVb8LzwsAAWxxwwvIC+UibWVudACgCyL1JGlsaWJyaXVtAKDLIXAmRXF1aWxpYnJpdW0AAKBvKXIAAKAcIW8AoWPnIWh0AARBQ0RGVFVWYewLCgwQDDIMNwxeDHwM9gIAAW5y8Av4C2clbGVCcmFja2V0AACg6SfyIW93AKGSIUJM/wsDDGEAcgAAoOUhZSRmdEFycm93AACgxCFlI2lsaW5nAACgCSNvAPUBFgwAAB4MYiVsZUJyYWNrZXQAAKDnJ24A1AEjDAAAKgxlJGVWZWN0b3IAAKBdKeUiY3RvckKgwiFhAHIAAKBVKWwib29yAACgCyMAAWVyOwxLDGUAAKGiIkFWQQxGDHIicm93AACgpiHlImN0b3IAoFspaSNhbmdsZQBCorMiVgwAAAAAWgxhAHIAAKDQKXEidWFsAACgtSJwAIABRFRWAGUMbAxzDO8kd25WZWN0b3IAoE8pZSRlVmVjdG9yAACgXCnlImN0b3JCoL4hYQByAACgVCnlImN0b3JCoMAhYQByAACgUykAAXB1iQyMDGYAAKAdIe4kZEltcGxpZXMAoHAp6SRnaHRhcnJvdwCg2yEAAWNongyhDHIAAKAbIQCgsSHsJGVEZWxheWVkAKD0KYAGSE9hY2ZoaW1vcXN0dQC/DMgMzAzQDOIM5gwKDQ0NFA0ZDU8NVA1YDQABQ2PDDMYMyCFjeSlkeQAoZEYiVGN5ACxkYyJ1dGUAWmEAorwqYWVpedgM2wzeDOEM8iFvbmBh5CFpbF5hcgBjAFxhIWRyAADgNdgW3e8hcnQAAkRMUlXvDPYM/QwEDW8kd25BcnJvdwAAoJMhZSRmdEFycm93AACgkCHpJGdodEFycm93AKCSIXAjQXJyb3cAAKCRIechbWGjY+EkbGxDaXJjbGUAoBgicABmAADgNdhK3XICHw0AAAAAIg10AACgGiLhIXJlgKGhJUlTVQAqDTINSg3uJXRlcnNlY3Rpb24AoJMidQAAAWJwNw1ADfMhZXRFoI8icSJ1YWwAAKCRIuUicnNldEWgkCJxInVhbAAAoJIibiJpb24AAKCUImMAcgAA4DXYrtxhAHIAAKDGIgACYmNtcF8Nag2ODZANc6DQImUAdABFoNAicSJ1YWwAAKCGIgABY2huDYkNZSJlZHMAgKF7IkVTVAB4DX0NhA1xInVhbAAAoLAq7CRhbnRFcXVhbACgfSJpImxkZQAAoH8iVABoAGEA9ADHCwCgESIAodEiZXOVDZ8NciJzZXQARaCDInEidWFsAACghyJlAHQAAKDRIoAFSFJTYWNmaGlvcnMAtQ27Db8NyA3ODdsN3w3+DRgOHQ4jDk8AUgBOADuA3gDeQMEhREUAoCIhAAFIY8MNxg1jAHkAC2R5ACZkAAFidcwNzQ0JYKRjgAFhZXkA1A3XDdoN8iFvbmRh5CFpbGJhImRyAADgNdgX3QABZWnjDe4N8gHoDQAA7Q3lImZvcmUAoDQiYQCYYwABY27yDfkNayNTcGFjZQAA4F8gCiDTInBhY2UAoAkg7CFkZYChPCJFRlQABw4MDhMOcSJ1YWwAAKBDInUkbGxFcXVhbAAAoEUiaSJsZGUAAKBIInAAZgAA4DXYS93pI3BsZURvdACg2yAAAWN0Jw4rDnIAAOA12K/c8iFva2Zh4QpFDlYOYA5qDgAAbg5yDgAAAAAAAAAAAAB5DnwOqA6zDgAADg8RDxYPGg8AAWNySA5ODnUAdABlADuA2gDaQHIAb6CfIeMhaXIAoEkpcgDjAVsOAABdDnkADmR2AGUAbGEAAWl5Yw5oDnIAYwA7gNsA20AjZGIibGFjAHBhcgAA4DXYGN1yAGEAdgBlADuA2QDZQOEhY3JqYQABZGl/Dp8OZQByAAABQlCFDpcOAAFhcokOiw5yAF9gYQBjAAABZWuRDpMOAKDfI2UAdAAAoLUjYSVyZW50aGVzaXMAAKDdI28AbgBQoMMi7CF1cwCgjiIAAWdwqw6uDm8AbgByYWYAAOA12EzdAARBREVUYWRwc78O0g7ZDuEOBQPqDvMOBw9yInJvdwDCoZEhyA4AAMwOYQByAACgEilvJHduQXJyb3cAAKDFIW8kd25BcnJvdwAAoJUhcSV1aWxpYnJpdW0AAKBuKWUAZQBBoKUiciJyb3cAAKClIW8AdwBuAGEAcgByAG8A9wAQA2UAcgAAAUxS+Q4AD2UkZnRBcnJvdwAAoJYh6SRnaHRBcnJvdwCglyFpAGyg0gNvAG4ApWPpIW5nbmFjAHIAAOA12LDcaSJsZGUAaGFtAGwAO4DcANxAgAREYmNkZWZvc3YALQ8xDzUPNw89D3IPdg97D4AP4SFzaACgqyJhAHIAAKDrKnkAEmThIXNobKCpIgCg5ioAAWVyQQ9DDwCgwSKAAWJ0eQBJD00Paw9hAHIAAKAWIGmgFiDjIWFsAAJCTFNUWA9cD18PZg9hAHIAAKAjIukhbmV8YGUkcGFyYXRvcgAAoFgnaSJsZGUAAKBAItQkaGluU3BhY2UAoAogcgAA4DXYGd1wAGYAAOA12E3dYwByAADgNdix3GQiYXNoAACgqiKAAmNlZm9zAI4PkQ+VD5kPng/pIXJjdGHkIWdlAKDAInIAAOA12BrdcABmAADgNdhO3WMAcgAA4DXYstwAAmZpb3OqD64Prw+0D3IAAOA12BvdnmNwAGYAAOA12E/dYwByAADgNdiz3IAEQUlVYWNmb3N1AMgPyw/OD9EP2A/gD+QP6Q/uD2MAeQAvZGMAeQAHZGMAeQAuZGMAdQB0AGUAO4DdAN1AAAFpedwP3w9yAGMAdmErZHIAAOA12BzdcABmAADgNdhQ3WMAcgAA4DXYtNxtAGwAeGEABEhhY2RlZm9z/g8BEAUQDRAQEB0QIBAkEGMAeQAWZGMidXRlAHlhAAFheQkQDBDyIW9ufWEXZG8AdAB7YfIBFRAAABwQbwBXAGkAZAB0AOgAVAhhAJZjcgAAoCghcABmAACgJCFjAHIAAOA12LXc4QtCEEkQTRAAAGcQbRByEAAAAAAAAAAAeRCKEJcQ8hD9EAAAGxEhETIROREAAD4RYwB1AHQAZQA7gOEA4UByImV2ZQADYYCiPiJFZGl1eQBWEFkQWxBgEGUQAOA+IjMDAKA/InIAYwA7gOIA4kB0AGUAO4C0ALRAMGRsAGkAZwA7gOYA5kByoGEgAOA12B7dcgBhAHYAZQA7gOAA4EAAAWVwfBCGEAABZnCAEIQQ8yF5bQCgNSHoAIMQaABhALFjAAFhcI0QWwAAAWNskRCTEHIAAWFnAACgPypkApwQAAAAALEQAKInImFkc3ajEKcQqRCuEG4AZAAAoFUqAKBcKmwib3BlAACgWCoAoFoqAKMgImVsbXJzersQvRDAEN0Q5RDtEACgpCllAACgICJzAGQAYaAhImEEzhDQENIQ1BDWENgQ2hDcEACgqCkAoKkpAKCqKQCgqykAoKwpAKCtKQCgrikAoK8pdAB2oB8iYgBkoL4iAKCdKQABcHTpEOwQaAAAoCIixWDhIXJyAKB8IwABZ3D1EPgQbwBuAAVhZgAA4DXYUt0Ao0giRWFlaW9wBxEJEQ0RDxESERQRAKBwKuMhaXIAoG8qAKBKImQAAKBLInMAJ2DyIW94ZaBIIvEADhFpAG4AZwA7gOUA5UCAAWN0eQAmESoRKxFyAADgNdi23CpgbQBwAGWgSCLxAPgBaQBsAGQAZQA7gOMA40BtAGwAO4DkAORAAAFjaUERRxFvAG4AaQBuAPQA6AFuAHQAAKARKgAITmFiY2RlZmlrbG5vcHJzdWQRaBGXEZ8RpxGrEdIR1hErEjASexKKEn0RThNbE3oTbwB0AACg7SoAAWNybBGJEWsAAAJjZXBzdBF4EX0RghHvIW5nAKBMInAjc2lsb24A9mNyImltZQAAoDUgaQBtAGWgPSJxAACgzSJ2AY0RkRFlAGUAAKC9ImUAZABnoAUjZQAAoAUjcgBrAHSgtSPiIXJrAKC2IwABb3mjEaYRbgDnAHcRMWTxIXVvAKAeIIACY21wcnQAtBG5Eb4RwRHFEeEhdXPloDUi5ABwInR5dgAAoLApcwDpAH0RbgBvAPUA6gCAAWFodwDLEcwRzhGyYwCgNiHlIWVuAKBsInIAAOA12B/dZwCAA2Nvc3R1dncA4xHyEQUSEhIhEiYSKRKAAWFpdQDpEesR7xHwAKMFcgBjAACg7yVwAACgwyKAAWRwdAD4EfwRABJvAHQAAKAAKuwhdXMAoAEqaSJtZXMAAKACKnECCxIAAAAADxLjIXVwAKAGKmEAcgAAoAUm8iNpYW5nbGUAAWR1GhIeEu8hd24AoL0lcAAAoLMlcCJsdXMAAKAEKmUA5QBCD+UAkg9hInJvdwAAoA0pgAFha28ANhJoEncSAAFjbjoSZRJrAIABbHN0AEESRxJNEm8jemVuZ2UAAKDrKXEAdQBhAHIA5QBcBPIjaWFuZ2xlgKG0JWRscgBYElwSYBLvIXduAKC+JeUhZnQAoMIlaSJnaHQAAKC4JWsAAKAjJLEBbRIAAHUSsgFxEgAAcxIAoJIlAKCRJTQAAKCTJWMAawAAoIglAAFlb38ShxJx4D0A5SD1IWl2AOBhIuUgdAAAoBAjAAJwdHd4kRKVEpsSnxJmAADgNdhT3XSgpSJvAG0AAKClIvQhaWUAoMgiAAZESFVWYmRobXB0dXayEsES0RLgEvcS+xIKExoTHxMjEygTNxMAAkxSbHK5ErsSvRK/EgCgVyUAoFQlAKBWJQCgUyUAolAlRFVkdckSyxLNEs8SAKBmJQCgaSUAoGQlAKBnJQACTFJsctgS2hLcEt4SAKBdJQCgWiUAoFwlAKBZJQCjUSVITFJobHLrEu0S7xLxEvMS9RIAoGwlAKBjJQCgYCUAoGslAKBiJQCgXyVvAHgAAKDJKQACTFJscgITBBMGEwgTAKBVJQCgUiUAoBAlAKAMJQCiACVEVWR1EhMUExYTGBMAoGUlAKBoJQCgLCUAoDQlaSJudXMAAKCfIuwhdXMAoJ4iaSJtZXMAAKCgIgACTFJsci8TMRMzEzUTAKBbJQCgWCUAoBglAKAUJQCjAiVITFJobHJCE0QTRhNIE0oTTBMAoGolAKBhJQCgXiUAoDwlAKAkJQCgHCUAAWV2UhNVE3YA5QD5AGIAYQByADuApgCmQAACY2Vpb2ITZhNqE24TcgAA4DXYt9xtAGkAAKBPIG0A5aA9IogRbAAAoVwAYmh0E3YTAKDFKfMhdWIAoMgnbAF+E4QTbABloCIgdAAAoCIgcAAAoU4iRWWJE4sTAKCuKvGgTyI8BeEMqRMAAN8TABQDFB8UAAAjFDQUAAAAAIUUAAAAAI0UAAAAANcU4xT3FPsUAACIFQAAlhWAAWNwcgCuE7ET1RP1IXRlB2GAoikiYWJjZHMAuxO/E8QTzhPSE24AZAAAoEQqciJjdXAAAKBJKgABYXXIE8sTcAAAoEsqcAAAoEcqbwB0AACgQCoA4CkiAP4AAWVv2RPcE3QAAKBBIO4ABAUAAmFlaXXlE+8T9RP4E/AB6hMAAO0TcwAAoE0qbwBuAA1hZABpAGwAO4DnAOdAcgBjAAlhcABzAHOgTCptAACgUCpvAHQAC2GAAWRtbgAIFA0UEhRpAGwAO4C4ALhAcCJ0eXYAAKCyKXQAAIGiADtlGBQZFKJAcgBkAG8A9ABiAXIAAOA12CDdgAFjZWkAKBQqFDIUeQBHZGMAawBtoBMn4SFyawCgEyfHY3IAAKPLJUVjZWZtcz8UQRRHFHcUfBSAFACgwykAocYCZWxGFEkUcQAAoFciZQBhAlAUAAAAAGAUciJyb3cAAAFsclYUWhTlIWZ0AKC6IWkiZ2h0AACguyGAAlJTYWNkAGgUaRRrFG8UcxSuYACgyCRzAHQAAKCbIukhcmMAoJoi4SFzaACgnSJuImludAAAoBAqaQBkAACg7yrjIWlyAKDCKfUhYnN1oGMmaQB0AACgYybsApMUmhS2FAAAwxRvAG4AZaA6APGgVCKrAG0CnxQAAAAAoxRhAHSgLABAYAChASJmbKcUqRTuABMNZQAAAW14rhSyFOUhbnQAoAEiZQDzANIB5wG6FAAAwBRkoEUibwB0AACgbSpuAPQAzAGAAWZyeQDIFMsUzhQA4DXYVN1vAOQA1wEAgakAO3MeAdMUcgAAoBchAAFhb9oU3hRyAHIAAKC1IXMAcwAAoBcnAAFjdeYU6hRyAADgNdi43AABYnDuFPIUZaDPKgCg0SploNAqAKDSKuQhb3QAoO8igANkZWxwcnZ3AAYVEBUbFSEVRBVlFYQV4SFycgABbHIMFQ4VAKA4KQCgNSlwAhYVAAAAABkVcgAAoN4iYwAAoN8i4SFycnCgtiEAoD0pgKIqImJjZG9zACsVMBU6FT4VQRVyImNhcAAAoEgqAAFhdTQVNxVwAACgRipwAACgSipvAHQAAKCNInIAAKBFKgDgKiIA/gACYWxydksVURVuFXMVcgByAG2gtyEAoDwpeQCAAWV2dwBYFWUVaRVxAHACXxUAAAAAYxVyAGUA4wAXFXUA4wAZFWUAZQAAoM4iZSJkZ2UAAKDPImUAbgA7gKQApEBlI2Fycm93AAABbHJ7FX8V5SFmdACgtiFpImdodAAAoLchZQDkAG0VAAFjaYsVkRVvAG4AaQBuAPQAkwFuAHQAAKAxImwiY3R5AACgLSOACUFIYWJjZGVmaGlqbG9yc3R1d3oAuBW7Fb8V1RXgFegV+RUKFhUWHxZUFlcWZRbFFtsW7xb7FgUXChdyAPIAtAJhAHIAAKBlKQACZ2xyc8YVyhXOFdAV5yFlcgCgICDlIXRoAKA4IfIA9QxoAHagECAAoKMiawHZFd4VYSJyb3cAAKAPKWEA4wBfAgABYXnkFecV8iFvbg9hNGQAoUYhYW/tFfQVAAFnciEC8RVyAACgyiF0InNlcQAAoHcqgAFnbG0A/xUCFgUWO4CwALBAdABhALRjcCJ0eXYAAKCxKQABaXIOFhIW8yFodACgfykA4DXYId1hAHIAAAFschsWHRYAoMMhAKDCIYACYWVnc3YAKBauAjYWOhY+Fm0AAKHEIm9zLhY0Fm4AZABzoMQi9SFpdACgZiZhIm1tYQDdY2kAbgAAoPIiAKH3AGlvQxZRFmQAZQAAgfcAO29KFksW90BuI3RpbWVzAACgxyJuAPgAUBZjAHkAUmRjAG8CXhYAAAAAYhZyAG4AAKAeI28AcAAAoA0jgAJscHR1dwBuFnEWdRaSFp4W7CFhciRgZgAA4DXYVd0AotkCZW1wc30WhBaJFo0WcQBkoFAibwB0AACgUSJpIm51cwAAoDgi7CF1cwCgFCLxInVhcmUAoKEiYgBsAGUAYgBhAHIAdwBlAGQAZwDlANcAbgCAAWFkaAClFqoWtBZyAHIAbwD3APUMbwB3AG4AYQByAHIAbwB3APMA8xVhI3Jwb29uAAABbHK8FsAWZQBmAPQAHBZpAGcAaAD0AB4WYgHJFs8WawBhAHIAbwD3AJILbwLUFgAAAADYFnIAbgAAoB8jbwBwAACgDCOAAWNvdADhFukW7BYAAXJ55RboFgDgNdi53FVkbAAAoPYp8iFvaxFhAAFkcvMW9xZvAHQAAKDxImkA5qC/JVsSAAFhaP8WAhdyAPIANQNhAPIA1wvhIm5nbGUAoKYpAAFjaQ4XEBd5AF9k5yJyYXJyAKD/JwAJRGFjZGVmZ2xtbm9wcXJzdHV4MRc4F0YXWxcyBF4XaRd5F40XrBe0F78X2RcVGCEYLRg1GEAYAAFEbzUXgRZvAPQA+BUAAWNzPBdCF3UAdABlADuA6QDpQPQhZXIAoG4qAAJhaW95TRdQF1YXWhfyIW9uG2FyAGOgViI7gOoA6kDsIW9uAKBVIk1kbwB0ABdhAAFEcmIXZhdvAHQAAKBSIgDgNdgi3XKhmipuF3QXYQB2AGUAO4DoAOhAZKCWKm8AdAAAoJgqgKGZKmlscwCAF4UXhxfuInRlcnMAoOcjAKATIWSglSpvAHQAAKCXKoABYXBzAJMXlheiF2MAcgATYXQAeQBzogUinxcAAAAAoRdlAHQAAKAFInAAMaADIDMBqRerFwCgBCAAoAUgAAFnc7AXsRdLYXAAAKACIAABZ3C4F7sXbwBuABlhZgAA4DXYVt2AAWFscwDFF8sXzxdyAHOg1SJsAACg4yl1AHMAAKBxKmkAAKG1A2x21RfYF28AbgC1Y/VjAAJjc3V24BfoF/0XEBgAAWlv5BdWF3IAYwAAoFYiaQLuFwAAAADwF+0ADQThIW50AAFnbPUX+Rd0AHIAAKCWKuUhc3MAoJUqgAFhZWkAAxgGGAoYbABzAD1gcwB0AACgXyJ2AESgYSJEAACgeCrwImFyc2wAoOUpAAFEYRkYHRhvAHQAAKBTInIAcgAAoHEpgAFjZGkAJxgqGO0XcgAAoC8hbwD0AIwCAAFhaDEYMhi3YzuA8ADwQAABbXI5GD0YbAA7gOsA60BvAACgrCCAAWNpcABGGEgYSxhsACFgcwD0ACwEAAFlb08YVxhjAHQAYQB0AGkAbwDuABoEbgBlAG4AdABpAGEAbADlADME4Ql1GAAAgRgAAIMYiBgAAAAAoRilGAAAqhgAALsYvhjRGAAA1xgnGWwAbABpAG4AZwBkAG8AdABzAGUA8QBlF3kARGRtImFsZQAAoEAmgAFpbHIAjRiRGJ0Y7CFpZwCgA/tpApcYAAAAAJoYZwAAoAD7aQBnAACgBPsA4DXYI93sIWlnAKAB++whaWcA4GYAagCAAWFsdACvGLIYthh0AACgbSZpAGcAAKAC+24AcwAAoLElbwBmAJJh8AHCGAAAxhhmAADgNdhX3QABYWvJGMwYbADsAGsEdqDUIgCg2SphI3J0aW50AACgDSoAAWFv2hgiGQABY3PeGB8ZsQPnGP0YBRkSGRUZAAAdGbID7xjyGPQY9xj5GAAA+xg7gL0AvUAAoFMhO4C8ALxAAKBVIQCgWSEAoFshswEBGQAAAxkAoFQhAKBWIbQCCxkOGQAAAAAQGTuAvgC+QACgVyEAoFwhNQAAoFghtgEZGQAAGxkAoFohAKBdITgAAKBeIWwAAKBEIHcAbgAAoCIjYwByAADgNdi73IAIRWFiY2RlZmdpamxub3JzdHYARhlKGVoZXhlmGWkZkhmWGZkZnRmgGa0ZxhnLGc8Z4BkjGmygZyIAoIwqgAFjbXAAUBlTGVgZ9SF0ZfVhbQBhAOSgswM6FgCghipyImV2ZQAfYQABaXliGWUZcgBjAB1hM2RvAHQAIWGAoWUibHFzAMYEcBl6GfGhZSLOBAAAdhlsAGEAbgD0AN8EgKF+KmNkbACBGYQZjBljAACgqSpvAHQAb6CAKmyggioAoIQqZeDbIgD+cwAAoJQqcgAA4DXYJN3noGsirATtIWVsAKA3IWMAeQBTZIChdyJFYWoApxmpGasZAKCSKgCgpSoAoKQqAAJFYWVztBm2Gb0ZwhkAoGkicABwoIoq8iFveACgiipxoIgq8aCIKrUZaQBtAACg5yJwAGYAAOA12FjdYQB2AOUAYwIAAWNp0xnWGXIAAKAKIW0AAKFzImVs3BneGQCgjioAoJAqAIM+ADtjZGxxco0E6xn0GfgZ/BkBGgABY2nvGfEZAKCnKnIAAKB6Km8AdAAAoNci0CFhcgCglSl1ImVzdAAAoHwqgAJhZGVscwAKGvQZFhrVBCAa8AEPGgAAFBpwAHIAbwD4AFkZcgAAoHgpcQAAAWxxxAQbGmwAZQBzAPMASRlpAO0A5AQAAWVuJxouGnIjdG5lcXEAAOBpIgD+xQAsGgAFQWFiY2Vma29zeUAaQxpmGmoabRqDGocalhrCGtMacgDyAMwCAAJpbG1yShpOGlAaVBpyAHMA8ABxD2YAvWBpAGwA9AASBQABZHJYGlsaYwB5AEpkAKGUIWN3YBpkGmkAcgAAoEgpAKCtIWEAcgAAoA8h6SFyYyVhgAFhbHIAcxp7Gn8a8iF0c3WgZSZpAHQAAKBlJuwhaXAAoCYg4yFvbgCguSJyAADgNdgl3XMAAAFld4wakRphInJvdwAAoCUpYSJyb3cAAKAmKYACYW1vcHIAnxqjGqcauhq+GnIAcgAAoP8h9CFodACgOyJrAAABbHKsGrMaZSRmdGFycm93AACgqSHpJGdodGFycm93AKCqIWYAAOA12Fnd4iFhcgCgFSCAAWNsdADIGswa0BpyAADgNdi93GEAcwDoAGka8iFvaydhAAFicNca2xr1IWxsAKBDIOghZW4AoBAg4Qr2GgAA/RoAAAgbExsaGwAAIRs7GwAAAAA+G2IbmRuVG6sbAACyG80b0htjAHUAdABlADuA7QDtQAChYyBpeQEbBhtyAGMAO4DuAO5AOGQAAWN4CxsNG3kANWRjAGwAO4ChAKFAAAFmcssCFhsA4DXYJt1yAGEAdgBlADuA7ADsQIChSCFpbm8AJxsyGzYbAAFpbisbLxtuAHQAAKAMKnQAAKAtIuYhaW4AoNwpdABhAACgKSHsIWlnM2GAAWFvcABDG1sbXhuAAWNndABJG0sbWRtyACthgAFlbHAAcQVRG1UbaQBuAOUAyAVhAHIA9AByBWgAMWFmAACgtyJlAGQAtWEAoggiY2ZvdGkbbRt1G3kb4SFyZQCgBSFpAG4AdKAeImkAZQAAoN0pZABvAPQAWxsAoisiY2VscIEbhRuPG5QbYQBsAACguiIAAWdyiRuNG2UAcgDzACMQ4wCCG2EicmhrAACgFyryIW9kAKA8KgACY2dwdJ8boRukG6gbeQBRZG8AbgAvYWYAAOA12FrdYQC5Y3UAZQBzAHQAO4C/AL9AAAFjabUbuRtyAADgNdi+3G4AAKIIIkVkc3bCG8QbyBvQAwCg+SJvAHQAAKD1Inag9CIAoPMiaaBiIOwhZGUpYesB1hsAANkbYwB5AFZkbAA7gO8A70AAA2NmbW9zdeYb7hvyG/Ub+hsFHAABaXnqG+0bcgBjADVhOWRyAADgNdgn3eEhdGg3YnAAZgAA4DXYW93jAf8bAAADHHIAAOA12L/c8iFjeVhk6yFjeVRkAARhY2ZnaGpvcxUcGhwiHCYcKhwtHDAcNRzwIXBhdqC6A/BjAAFleR4cIRzkIWlsN2E6ZHIAAOA12CjdciJlZW4AOGFjAHkARWRjAHkAXGRwAGYAAOA12FzdYwByAADgNdjA3IALQUJFSGFiY2RlZmdoamxtbm9wcnN0dXYAXhxtHHEcdRx5HN8cBx0dHTwd3B3tHfEdAR4EHh0eLB5FHrwewx7hHgkfPR9LH4ABYXJ0AGQcZxxpHHIA8gBvB/IAxQLhIWlsAKAbKeEhcnIAoA4pZ6BmIgCgiyphAHIAAKBiKWMJjRwAAJAcAACVHAAAAAAAAAAAAACZHJwcAACmHKgcrRwAANIc9SF0ZTph7SJwdHl2AKC0KXIAYQDuAFoG4iFkYbtjZwAAoegnZGyhHKMcAKCRKeUAiwYAoIUqdQBvADuAqwCrQHIAgKOQIWJmaGxwc3QAuhy/HMIcxBzHHMoczhxmoOQhcwAAoB8pcwAAoB0p6wCyGnAAAKCrIWwAAKA5KWkAbQAAoHMpbAAAoKIhAKGrKmFl1hzaHGkAbAAAoBkpc6CtKgDgrSoA/oABYWJyAOUc6RztHHIAcgAAoAwpcgBrAACgcicAAWFr8Rz4HGMAAAFla/Yc9xx7YFtgAAFlc/wc/hwAoIspbAAAAWR1Ax0FHQCgjykAoI0pAAJhZXV5Dh0RHRodHB3yIW9uPmEAAWRpFR0YHWkAbAA8YewAowbiAPccO2QAAmNxcnMkHScdLB05HWEAAKA2KXUAbwDyoBwgqhEAAWR1MB00HeghYXIAoGcpcyJoYXIAAKBLKWgAAKCyIQCiZCJmZ3FzRB1FB5Qdnh10AIACYWhscnQATh1WHWUdbB2NHXIicm93AHSgkCFhAOkAzxxhI3Jwb29uAAABZHVeHWId7yF3bgCgvSFwAACgvCHlJGZ0YXJyb3dzAKDHIWkiZ2h0AIABYWhzAHUdex2DHXIicm93APOglCGdBmEAcgBwAG8AbwBuAPMAzgtxAHUAaQBnAGEAcgByAG8A9wBlGugkcmVldGltZXMAoMsi8aFkIk0HAACaHWwAYQBuAPQAXgcAon0qY2Rnc6YdqR2xHbcdYwAAoKgqbwB0AG+gfypyoIEqAKCDKmXg2iIA/nMAAKCTKoACYWRlZ3MAwB3GHcod1h3ZHXAAcAByAG8A+ACmHG8AdAAAoNYicQAAAWdxzx3SHXQA8gBGB2cAdADyAHQcdADyAFMHaQDtAGMHgAFpbHIA4h3mHeod8yFodACgfClvAG8A8gDKBgDgNdgp3UWgdiIAoJEqYQH1Hf4dcgAAAWR1YB35HWygvCEAoGopbABrAACghCVjAHkAWWQAomoiYWNodAweDx4VHhkecgDyAGsdbwByAG4AZQDyAGAW4SFyZACgaylyAGkAAKD6JQABaW8hHiQe5CFvdEBh9SFzdGGgsCPjIWhlAKCwIwACRWFlczMeNR48HkEeAKBoInAAcKCJKvIhb3gAoIkqcaCHKvGghyo0HmkAbQAAoOYiAARhYm5vcHR3elIeXB5fHoUelh6mHqsetB4AAW5yVh5ZHmcAAKDsJ3IAAKD9IXIA6wCwBmcAgAFsbXIAZh52Hnse5SFmdAABYXKIB2weaQBnAGgAdABhAHIAcgBvAPcAkwfhInBzdG8AoPwnaQBnAGgAdABhAHIAcgBvAPcAmgdwI2Fycm93AAABbHKNHpEeZQBmAPQAxhxpImdodAAAoKwhgAFhZmwAnB6fHqIecgAAoIUpAOA12F3ddQBzAACgLSppIm1lcwAAoDQqYQGvHrMecwB0AACgFyLhAIoOZaHKJbkeRhLuIWdlAKDKJWEAcgBsoCgAdAAAoJMpgAJhY2htdADMHs8e1R7bHt0ecgDyAJ0GbwByAG4AZQDyANYWYQByAGSgyyEAoG0pAKAOIHIAaQAAoL8iAANhY2hpcXTrHu8e1QfzHv0eBh/xIXVvAKA5IHIAAOA12MHcbQDloXIi+h4AAPweAKCNKgCgjyoAAWJ19xwBH28AcqAYIACgGiDyIW9rQmEAhDwAO2NkaGlscXJCBhcfxh0gHyQfKB8sHzEfAAFjaRsfHR8AoKYqcgAAoHkqcgBlAOUAkx3tIWVzAKDJIuEhcnIAoHYpdSJlc3QAAKB7KgABUGk1HzkfYQByAACglillocMlAgdfEnIAAAFkdUIfRx9zImhhcgAAoEop6CFhcgCgZikAAWVuTx9WH3IjdG5lcXEAAOBoIgD+xQBUHwAHRGFjZGVmaGlsbm9wc3VuH3Ifoh+rH68ftx+7H74f5h/uH/MfBwj/HwsgxCFvdACgOiIAAmNscHJ5H30fiR+eH3IAO4CvAK9AAAFldIEfgx8AoEImZaAgJ3MAZQAAoCAnc6CmIXQAbwCAoaYhZGx1AJQfmB+cH28AdwDuAHkDZQBmAPQA6gbwAOkO6yFlcgCgriUAAW95ph+qH+0hbWEAoCkqPGThIXNoAKAUIOElc3VyZWRhbmdsZQCgISJyAADgNdgq3W8AAKAnIYABY2RuAMQfyR/bH3IAbwA7gLUAtUBhoiMi0B8AANMf1x9zAPQAKxFpAHIAAKDwKm8AdAA7gLcAt0B1AHMA4qESIh4TAADjH3WgOCIAoCoqYwHqH+0fcAAAoNsq8gB+GnAAbAB1APMACAgAAWRw9x/7H+UhbHMAoKciZgAA4DXYXt0AAWN0AyAHIHIAAOA12MLc8CFvcwCgPiJsobwDECAVIPQiaW1hcACguCJhAPAAEyAADEdMUlZhYmNkZWZnaGlqbG1vcHJzdHV2dzwgRyBmIG0geSCqILgg2iDeIBEhFSEyIUMhTSFQIZwhnyHSIQAiIyKLIrEivyIUIwABZ3RAIEMgAODZIjgD9uBrItIgBwmAAWVsdABNIF8gYiBmAHQAAAFhclMgWCByInJvdwAAoM0h6SRnaHRhcnJvdwCgziEA4NgiOAP24Goi0iBfCekkZ2h0YXJyb3cAoM8hAAFEZHEgdSDhIXNoAKCvIuEhc2gAoK4igAJiY25wdACCIIYgiSCNIKIgbABhAACgByL1IXRlRGFnAADgICLSIACiSSJFaW9wlSCYIJwgniAA4HAqOANkAADgSyI4A3MASWFyAG8A+AAyCnUAcgBhoG4mbADzoG4mmwjzAa8gAACzIHAAO4CgAKBAbQBwAOXgTiI4AyoJgAJhZW91eQDBIMogzSDWINkg8AHGIAAAyCAAoEMqbwBuAEhh5CFpbEZhbgBnAGSgRyJvAHQAAOBtKjgDcAAAoEIqPWThIXNoAKATIACjYCJBYWRxc3jpIO0g+SD+IAIhDCFyAHIAAKDXIXIAAAFocvIg9SBrAACgJClvoJch9wAGD28AdAAA4FAiOAN1AGkA9gC7CAABZWkGIQohYQByAACgKCntAN8I6SFzdPOgBCLlCHIAAOA12CvdAAJFZXN0/wgcISshLiHxoXEiIiEAABMJ8aFxIgAJAAAnIWwAYQBuAPQAEwlpAO0AGQlyoG8iAKBvIoABQWFwADghOyE/IXIA8gBeIHIAcgAAoK4hYQByAACg8ipzogsiSiEAAAAAxwtkoPwiAKD6ImMAeQBaZIADQUVhZGVzdABcIV8hYiFmIWkhkyGWIXIA8gBXIADgZiI4A3IAcgAAoJohcgAAoCUggKFwImZxcwBwIYQhjiF0AAABYXJ1IXohcgByAG8A9wBlIWkAZwBoAHQAYQByAHIAbwD3AD4h8aFwImAhAACKIWwAYQBuAPQAZwlz4H0qOAMAoG4iaQDtAG0JcqBuImkA5aDqIkUJaQDkADoKAAFwdKMhpyFmAADgNdhf3YCBrAA7aW4AriGvIcchrEBuAIChCSJFZHYAtyG6Ib8hAOD5IjgDbwB0AADg9SI4A+EB1gjEIcYhAKD3IgCg9iJpAHagDCLhAagJzyHRIQCg/iIAoP0igAFhb3IA2CHsIfEhcgCAoSYiYXN0AOAh5SHpIWwAbABlAOwAywhsAADg/SrlIADgAiI4A2wiaW50AACgFCrjoYAi9yEAAPohdQDlAJsJY+CvKjgDZaCAIvEAkwkAAkFhaXQHIgoiFyIeInIA8gBsIHIAcgAAoZshY3cRIhQiAOAzKTgDAOCdITgDZyRodGFycm93AACgmyFyAGkA5aDrIr4JgANjaGltcHF1AC8iPCJHIpwhTSJQIloigKGBImNlcgA2Iv0JOSJ1AOUABgoA4DXYw9zvIXJ0bQKdIQAAAABEImEAcgDhAOEhbQBloEEi8aBEIiYKYQDyAMsIcwB1AAABYnBWIlgi5QDUCeUA3wmAAWJjcABgInMieCKAoYQiRWVzAGci7glqIgDgxSo4A2UAdABl4IIi0iBxAPGgiCJoImMAZaCBIvEA/gmAoYUiRWVzAH8iFgqCIgDgxio4A2UAdABl4IMi0iBxAPGgiSKAIgACZ2lscpIilCKaIpwi7AAMCWwAZABlADuA8QDxQOcAWwlpI2FuZ2xlAAABbHKkIqoi5SFmdGWg6iLxAEUJaSJnaHQAZaDrIvEAvgltoL0DAKEjAGVzuCK8InIAbwAAoBYhcAAAoAcggARESGFkZ2lscnMAziLSItYi2iLeIugi7SICIw8j4SFzaACgrSLhIXJyAKAEKXAAAOBNItIg4SFzaACgrCIAAWV04iLlIgDgZSLSIADgPgDSIG4iZmluAACg3imAAUFldADzIvci+iJyAHIAAKACKQDgZCLSIHLgPADSIGkAZQAA4LQi0iAAAUF0BiMKI3IAcgAAoAMp8iFpZQDgtSLSIGkAbQAA4Dwi0iCAAUFhbgAaIx4jKiNyAHIAAKDWIXIAAAFociMjJiNrAACgIylvoJYh9wD/DuUhYXIAoCcpUxJqFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVCMAAF4jaSN/I4IjjSOeI8AUAAAAAKYjwCMAANoj3yMAAO8jHiQvJD8kRCQAAWNzVyNsFHUAdABlADuA8wDzQAABaXlhI2cjcgBjoJoiO4D0APRAPmSAAmFiaW9zAHEjdCN3I3EBeiNzAOgAdhTsIWFjUWF2AACgOCrvIWxkAKC8KewhaWdTYQABY3KFI4kjaQByAACgvykA4DXYLN1vA5QjAAAAAJYjAACcI24A22JhAHYAZQA7gPIA8kAAoMEpAAFibaEjjAphAHIAAKC1KQACYWNpdKwjryO6I70jcgDyAFkUAAFpcrMjtiNyAACgvinvIXNzAKC7KW4A5QDZCgCgwCmAAWFlaQDFI8gjyyNjAHIATWFnAGEAyWOAAWNkbgDRI9Qj1iPyIW9uv2MAoLYpdQDzAHgBcABmAADgNdhg3YABYWVsAOQj5yPrI3IAAKC3KXIAcAAAoLkpdQDzAHwBAKMoImFkaW9zdvkj/CMPJBMkFiQbJHIA8gBeFIChXSplZm0AAyQJJAwkcgBvoDQhZgAAoDQhO4CqAKpAO4C6ALpA5yFvZgCgtiJyAACgVipsIm9wZQAAoFcqAKBbKoABY2xvACMkJSQrJPIACCRhAHMAaAA7gPgA+EBsAACgmCJpAGwBMyQ4JGQAZQA7gPUA9UBlAHMAYaCXInMAAKA2Km0AbAA7gPYA9kDiIWFyAKA9I+EKXiQAAHokAAB8JJQkAACYJKkkAAAAALUkEQsAAPAkAAAAAAQleiUAAIMlcgCAoSUiYXN0AGUkbyQBCwCBtgA7bGokayS2QGwAZQDsABgDaQJ1JAAAAAB4JG0AAKDzKgCg/Sp5AD9kcgCAAmNpbXB0AIUkiCSLJJkSjyRuAHQAJWBvAGQALmBpAGwAAKAwIOUhbmsAoDEgcgAA4DXYLd2AAWltbwCdJKAkpCR2oMYD1WNtAGEA9AD+B24AZQAAoA4m9KHAA64kAAC0JGMjaGZvcmsAAKDUItZjAAFhdbgkxCRuAAABY2u9JMIkawBooA8hAKAOIfYAaRpzAACkKwBhYmNkZW1zdNMkIRPXJNsk4STjJOck6yTjIWlyAKAjKmkAcgAAoCIqAAFvdYsW3yQAoCUqAKByKm4AO4CxALFAaQBtAACgJip3AG8AAKAnKoABaXB1APUk+iT+JO4idGludACgFSpmAADgNdhh3W4AZAA7gKMAo0CApHoiRWFjZWlub3N1ABMlFSUYJRslTCVRJVklSSV1JQCgsypwAACgtyp1AOUAPwtjoK8qgKJ6ImFjZW5zACclLSU0JTYlSSVwAHAAcgBvAPgAFyV1AHIAbAB5AGUA8QA/C/EAOAuAAWFlcwA8JUElRSXwInByb3gAoLkqcQBxAACgtSppAG0AAKDoImkA7QBEC20AZQDzoDIgIguAAUVhcwBDJVclRSXwAEAlgAFkZnAATwtfJXElgAFhbHMAZSVpJW0l7CFhcgCgLiPpIW5lAKASI/UhcmYAoBMjdKAdIu8AWQvyIWVsAKCwIgABY2l9JYElcgAA4DXYxdzIY24iY3NwAACgCCAAA2Zpb3BzdZElKxuVJZolnyWkJXIAAOA12C7dcABmAADgNdhi3XIiaW1lAACgVyBjAHIAAOA12MbcgAFhZW8AqiW6JcAldAAAAWVpryW2JXIAbgBpAG8AbgDzABkFbgB0AACgFipzAHQAZaA/APEACRj0AG0LgApBQkhhYmNkZWZoaWxtbm9wcnN0dXgA4yXyJfYl+iVpJpAmpia9JtUm5ib4JlonaCdxJ3UnnietJ7EnyCfiJ+cngAFhcnQA6SXsJe4lcgDyAJkM8gD6AuEhaWwAoBwpYQByAPIA3BVhAHIAAKBkKYADY2RlbnFydAAGJhAmEyYYJiYmKyZaJgABZXUKJg0mAOA9IjEDdABlAFVhaQDjACAN7SJwdHl2AKCzKWcAgKHpJ2RlbAAgJiImJCYAoJIpAKClKeUA9wt1AG8AO4C7ALtAcgAApZIhYWJjZmhscHN0dz0mQCZFJkcmSiZMJk4mUSZVJlgmcAAAoHUpZqDlIXMAAKAgKQCgMylzAACgHinrALka8ACVHmwAAKBFKWkAbQAAoHQpbAAAoKMhAKCdIQABYWleJmImaQBsAACgGilvAG6gNiJhAGwA8wB2C4ABYWJyAG8mciZ2JnIA8gAvEnIAawAAoHMnAAFha3omgSZjAAABZWt/JoAmfWBdYAABZXOFJocmAKCMKWwAAAFkdYwmjiYAoI4pAKCQKQACYWV1eZcmmiajJqUm8iFvbllhAAFkaZ4moSZpAGwAV2HsAA8M4gCAJkBkAAJjbHFzrSawJrUmuiZhAACgNylkImhhcgAAoGkpdQBvAPKgHSCjAWgAAKCzIYABYWNnAMMm0iaUC2wAgKEcIWlwcwDLJs4migxuAOUAoAxhAHIA9ADaC3QAAKCtJYABaWxyANsm3ybjJvMhaHQAoH0pbwBvAPIANgwA4DXYL90AAWFv6ib1JnIAAAFkde8m8SYAoMEhbKDAIQCgbCl2oMED8WOAAWducwD+Jk4nUCdoAHQAAANhaGxyc3QKJxInISc1Jz0nRydyInJvdwB0oJIhYQDpAFYmYSNycG9vbgAAAWR1GiceJ28AdwDuAPAmcAAAoMAh5SFmdAABYWgnJy0ncgByAG8AdwDzAAkMYQByAHAAbwBvAG4A8wATBGklZ2h0YXJyb3dzAACgySFxAHUAaQBnAGEAcgByAG8A9wBZJugkcmVldGltZXMAoMwiZwDaYmkAbgBnAGQAbwB0AHMAZQDxABwYgAFhaG0AYCdjJ2YncgDyAAkMYQDyABMEAKAPIG8idXN0AGGgsSPjIWhlAKCxI+0haWQAoO4qAAJhYnB0fCeGJ4knmScAAW5ygCeDJ2cAAKDtJ3IAAKD+IXIA6wAcDIABYWZsAI8nkieVJ3IAAKCGKQDgNdhj3XUAcwAAoC4qaSJtZXMAAKA1KgABYXCiJ6gncgBnoCkAdAAAoJQp7yJsaW50AKASKmEAcgDyADwnAAJhY2hxuCe8J6EMwCfxIXVvAKA6IHIAAOA12MfcAAFidYAmxCdvAPKgGSCoAYABaGlyAM4n0ifWJ3IAZQDlAE0n7SFlcwCgyiJpAIChuSVlZmwAXAxjEt4n9CFyaQCgzinsInVoYXIAoGgpAKAeIWENBSgJKA0oSyhVKIYoAACLKLAoAAAAAOMo5ygAABApJCkxKW0pcSmHKaYpAACYKgAAAACxKmMidXRlAFthcQB1AO8ABR+ApHsiRWFjZWlucHN5ABwoHignKCooLygyKEEoRihJKACgtCrwASMoAAAlKACguCpvAG4AYWF1AOUAgw1koLAqaQBsAF9hcgBjAF1hgAFFYXMAOCg6KD0oAKC2KnAAAKC6KmkAbQAAoOki7yJsaW50AKATKmkA7QCIDUFkbwB0AGKixSKRFgAAAABTKACgZiqAA0FhY21zdHgAYChkKG8ocyh1KHkogihyAHIAAKDYIXIAAAFocmkoayjrAJAab6CYIfcAzAd0ADuApwCnQGkAO2D3IWFyAKApKW0AAAFpbn4ozQBuAHUA8wDOAHQAAKA2J3IA7+A12DDdIxkAAmFjb3mRKJUonSisKHIAcAAAoG8mAAFoeZkonChjAHkASWRIZHIAdABtAqUoAAAAAKgoaQDkAFsPYQByAGEA7ABsJDuArQCtQAABZ22zKLsobQBhAAChwwNmdroouijCY4CjPCJkZWdsbnByAMgozCjPKNMo1yjaKN4obwB0AACgairxoEMiCw5FoJ4qAKCgKkWgnSoAoJ8qZQAAoEYi7CF1cwCgJCrhIXJyAKByKWEAcgDyAPwMAAJhZWl07Sj8KAEpCCkAAWxz8Sj4KGwAcwBlAHQAbQDpAH8oaABwAACgMyrwImFyc2wAoOQpAAFkbFoPBSllAACgIyNloKoqc6CsKgDgrCoA/oABZmxwABUpGCkfKfQhY3lMZGKgLwBhoMQpcgAAoD8jZgAA4DXYZN1hAAABZHIoKRcDZQBzAHWgYCZpAHQAAKBgJoABY3N1ADYpRilhKQABYXU6KUApcABzoJMiAOCTIgD+cABzoJQiAOCUIgD+dQAAAWJwSylWKQChjyJlcz4NUCllAHQAZaCPIvEAPw0AoZAiZXNIDVspZQB0AGWgkCLxAEkNAKGhJWFmZilbBHIAZQFrKVwEAKChJWEAcgDyAAMNAAJjZW10dyl7KX8pgilyAADgNdjI3HQAbQDuAM4AaQDsAAYpYQByAOYAVw0AAWFyiimOKXIA5qAGJhESAAFhbpIpoylpImdodAAAAWVwmSmgKXAAcwBpAGwAbwDuANkXaADpAKAkcwCvYIACYmNtbnAArin8KY4NJSooKgCkgiJFZGVtbnByc7wpvinCKcgpzCnUKdgp3CkAoMUqbwB0AACgvSpkoIYibwB0AACgwyr1IWx0AKDBKgABRWXQKdIpAKDLKgCgiiLsIXVzAKC/KuEhcnIAoHkpgAFlaXUA4inxKfQpdAAAoYIiZW7oKewpcQDxoIYivSllAHEA8aCKItEpbQAAoMcqAAFicPgp+ikAoNUqAKDTKmMAgKJ7ImFjZW5zAAcqDSoUKhYqRihwAHAAcgBvAPgAIyh1AHIAbAB5AGUA8QCDDfEAfA2AAWFlcwAcKiIqPShwAHAAcgBvAPgAPChxAPEAOShnAACgaiYApoMiMTIzRWRlaGxtbnBzPCo/KkIqRSpHKlIqWCpjKmcqaypzKncqO4C5ALlAO4CyALJAO4CzALNAAKDGKgABb3NLKk4qdAAAoL4qdQBiAACg2CpkoIcibwB0AACgxCpzAAABb3VdKmAqbAAAoMknYgAAoNcq4SFycgCgeyn1IWx0AKDCKgABRWVvKnEqAKDMKgCgiyLsIXVzAKDAKoABZWl1AH0qjCqPKnQAAKGDImVugyqHKnEA8aCHIkYqZQBxAPGgiyJwKm0AAKDIKgABYnCTKpUqAKDUKgCg1iqAAUFhbgCdKqEqrCpyAHIAAKDZIXIAAAFocqYqqCrrAJUab6CZIfcAxQf3IWFyAKAqKWwAaQBnADuA3wDfQOELzyrZKtwq6SrsKvEqAAD1KjQrAAAAAAAAAAAAAEwrbCsAAHErvSsAAAAAAADRK3IC1CoAAAAA2CrnIWV0AKAWI8RjcgDrAOUKgAFhZXkA4SrkKucq8iFvbmVh5CFpbGNhQmRvAPQAIg5sInJlYwAAoBUjcgAA4DXYMd0AAmVpa2/7KhIrKCsuK/IBACsAAAkrZQAAATRm6g0EK28AcgDlAOsNYQBzorgDECsAAAAAEit5AG0A0WMAAWNuFislK2sAAAFhcxsrIStwAHAAcgBvAPgAFw5pAG0AAKA8InMA8AD9DQABYXMsKyEr8AAXDnIAbgA7gP4A/kDsATgrOyswG2QA5QBnAmUAcwCAgdcAO2JkAEMrRCtJK9dAYaCgInIAAKAxKgCgMCqAAWVwcwBRK1MraSvhAAkh4qKkIlsrXysAAAAAYytvAHQAAKA2I2kAcgAAoPEqb+A12GXdcgBrAACg2irhAHgociJpbWUAAKA0IIABYWlwAHYreSu3K2QA5QC+DYADYWRlbXBzdACFK6MrmiunK6wrsCuzK24iZ2xlAACitSVkbHFykCuUK5ornCvvIXduAKC/JeUhZnRloMMl8QACBwCgXCJpImdodABloLkl8QBdDG8AdAAAoOwlaSJudXMAAKA6KuwhdXMAoDkqYgAAoM0p6SFtZQCgOyrlInppdW0AoOIjgAFjaHQAwivKK80rAAFyecYrySsA4DXYydxGZGMAeQBbZPIhb2tnYQABaW/UK9creAD0ANERaCJlYWQAAAFsct4r5ytlAGYAdABhAHIAcgBvAPcAXQbpJGdodGFycm93AKCgIQAJQUhhYmNkZmdobG1vcHJzdHV3CiwNLBEsHSwnLDEsQCxLLFIsYix6LIQsjyzLLOgs7Sz/LAotcgDyAAkDYQByAACgYykAAWNyFSwbLHUAdABlADuA+gD6QPIACQ1yAOMBIywAACUseQBeZHYAZQBtYQABaXkrLDAscgBjADuA+wD7QENkgAFhYmgANyw6LD0scgDyANEO7CFhY3FhYQDyAOAOAAFpckQsSCzzIWh0AKB+KQDgNdgy3XIAYQB2AGUAO4D5APlAYQFWLF8scgAAAWxyWixcLACgvyEAoL4hbABrAACggCUAAWN0Zix2LG8CbCwAAAAAcyxyAG4AZaAcI3IAAKAcI28AcAAAoA8jcgBpAACg+CUAAWFsfiyBLGMAcgBrYTuAqACoQAABZ3CILIssbwBuAHNhZgAA4DXYZt0AA2FkaGxzdZksniynLLgsuyzFLHIAcgBvAPcACQ1vAHcAbgBhAHIAcgBvAPcA2A5hI3Jwb29uAAABbHKvLLMsZQBmAPQAWyxpAGcAaAD0AF0sdQDzAKYOaQAAocUDaGzBLMIs0mNvAG4AxWPwI2Fycm93cwCgyCGAAWNpdADRLOEs5CxvAtcsAAAAAN4scgBuAGWgHSNyAACgHSNvAHAAAKAOI24AZwBvYXIAaQAAoPklYwByAADgNdjK3IABZGlyAPMs9yz6LG8AdAAAoPAi7CFkZWlhaQBmoLUlAKC0JQABYW0DLQYtcgDyAMosbAA7gPwA/EDhIm5nbGUAoKcpgAdBQkRhY2RlZmxub3Byc3oAJy0qLTAtNC2bLZ0toS2/LcMtxy3TLdgt3C3gLfwtcgDyABADYQByAHag6CoAoOkqYQBzAOgA/gIAAW5yOC08LechcnQAoJwpgANla25wcnN0AJkpSC1NLVQtXi1iLYItYQBwAHAA4QAaHG8AdABoAGkAbgDnAKEXgAFoaXIAoSmzJFotbwBwAPQAdCVooJUh7wD4JgABaXVmLWotZwBtAOEAuygAAWJwbi14LXMjZXRuZXEAceCKIgD+AODLKgD+cyNldG5lcQBx4IsiAP4A4MwqAP4AAWhyhi2KLWUAdADhABIraSNhbmdsZQAAAWxyki2WLeUhZnQAoLIiaSJnaHQAAKCzInkAMmThIXNoAKCiIoABZWxyAKcttC24LWKiKCKuLQAAAACyLWEAcgAAoLsicQAAoFoi7CFpcACg7iIAAWJ0vC1eD2EA8gBfD3IAAOA12DPddAByAOkAlS1zAHUAAAFicM0t0C0A4IIi0iAA4IMi0iBwAGYAAOA12GfdcgBvAPAAWQt0AHIA6QCaLQABY3XkLegtcgAA4DXYy9wAAWJw7C30LW4AAAFFZXUt8S0A4IoiAP5uAAABRWV/LfktAOCLIgD+6SJnemFnAKCaKYADY2Vmb3BycwANLhAuJS4pLiMuLi40LukhcmN1YQABZGkULiEuAAFiZxguHC5hAHIAAKBfKmUAcaAnIgCgWSLlIXJwAKAYIXIAAOA12DTdcABmAADgNdho3WWgQCJhAHQA6ABqD2MAcgAA4DXYzNzjCuQRUC4AAFQuAABYLmIuAAAAAGMubS5wLnQuAAAAAIguki4AAJouJxIqEnQAcgDpAB0ScgAA4DXYNd0AAUFhWy5eLnIA8gDnAnIA8gCTB75jAAFBYWYuaS5yAPIA4AJyAPIAjAdhAPAAeh5pAHMAAKD7IoABZHB0APgReS6DLgABZmx9LoAuAOA12GnddQDzAP8RaQBtAOUABBIAAUFhiy6OLnIA8gDuAnIA8gCaBwABY3GVLgoScgAA4DXYzdwAAXB0nS6hLmwAdQDzACUScgDpACASAARhY2VmaW9zdbEuvC7ELsguzC7PLtQu2S5jAAABdXm2LrsudABlADuA/QD9QE9kAAFpecAuwy5yAGMAd2FLZG4AO4ClAKVAcgAA4DXYNt1jAHkAV2RwAGYAAOA12GrdYwByAADgNdjO3AABY23dLt8ueQBOZGwAO4D/AP9AAAVhY2RlZmhpb3N38y73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg`),B1=R1(`AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg`);var V1;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.FLAG13=8192]=`FLAG13`,e[e.BRANCH_LENGTH=8064]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(V1||={});var H1;(function(e){e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_F=102]=`LOWER_F`,e[e.LOWER_X=120]=`LOWER_X`,e[e.LOWER_Z=122]=`LOWER_Z`,e[e.UPPER_A=65]=`UPPER_A`,e[e.UPPER_F=70]=`UPPER_F`,e[e.UPPER_Z=90]=`UPPER_Z`})(H1||={});function U1(e){return e>=H1.ZERO&&e<=H1.NINE}function W1(e){return e>=H1.UPPER_A&&e<=H1.UPPER_F||e>=H1.LOWER_A&&e<=H1.LOWER_F}function G1(e){return e>=H1.UPPER_A&&e<=H1.UPPER_Z||e>=H1.LOWER_A&&e<=H1.LOWER_Z||U1(e)}function K1(e){return e===H1.EQUALS||G1(e)}var q1;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(q1||={});var J1;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(J1||={});var Y1=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=q1.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=J1.Strict,this.runConsumed=0}startEntity(e){this.decodeMode=e,this.state=q1.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(e,t){switch(this.state){case q1.EntityStart:return e.charCodeAt(t)===H1.NUM?(this.state=q1.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=q1.NamedEntity,this.stateNamedEntity(e,t));case q1.NumericStart:return this.stateNumericStart(e,t);case q1.NumericDecimal:return this.stateNumericDecimal(e,t);case q1.NumericHex:return this.stateNumericHex(e,t);case q1.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|32)===H1.LOWER_X?(this.state=q1.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=q1.NumericDecimal,this.stateNumericDecimal(e,t))}stateNumericHex(e,t){for(;t<e.length;){let n=e.charCodeAt(t);if(U1(n)||W1(n)){let e=n<=H1.NINE?n-H1.ZERO:(n|32)-H1.LOWER_A+10;this.result=this.result*16+e,this.consumed++,t++}else return this.emitNumericEntity(n,3)}return-1}stateNumericDecimal(e,t){for(;t<e.length;){let n=e.charCodeAt(t);if(U1(n))this.result=this.result*10+(n-H1.ZERO),this.consumed++,t++;else return this.emitNumericEntity(n,2)}return-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)==null||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===H1.SEMI)this.consumed+=1;else if(this.decodeMode===J1.Strict)return 0;return this.emitCodePoint(L1(this.result),this.consumed),this.errors&&(e!==H1.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&V1.VALUE_LENGTH)>>14;for(;t<e.length;){if(i===0&&(r&V1.FLAG13)!==0){let a=(r&V1.BRANCH_LENGTH)>>7;if(this.runConsumed===0){let n=r&V1.JUMP_TABLE;if(e.charCodeAt(t)!==n)return this.result===0?0:this.emitNotTerminatedNamedEntity();t++,this.excess++,this.runConsumed++}for(;this.runConsumed<a;){if(t>=e.length)return-1;let r=this.runConsumed-1,i=n[this.treeIndex+1+(r>>1)],a=r%2==0?i&255:i>>8&255;if(e.charCodeAt(t)!==a)return this.runConsumed=0,this.result===0?0:this.emitNotTerminatedNamedEntity();t++,this.excess++,this.runConsumed++}this.runConsumed=0,this.treeIndex+=1+(a>>1),r=n[this.treeIndex],i=(r&V1.VALUE_LENGTH)>>14}if(t>=e.length)break;let a=e.charCodeAt(t);if(a===H1.SEMI&&i!==0&&(r&V1.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);if(this.treeIndex=X1(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===J1.Attribute&&(i===0||K1(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&V1.VALUE_LENGTH)>>14,i!==0){if(a===H1.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==J1.Strict&&(r&V1.FLAG13)===0&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}t++,this.excess++}return-1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:n}=this,r=(n[t]&V1.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)==null||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~(V1.VALUE_LENGTH|V1.FLAG13):r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case q1.NamedEntity:return this.result!==0&&(this.decodeMode!==J1.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case q1.NumericDecimal:return this.emitNumericEntity(0,2);case q1.NumericHex:return this.emitNumericEntity(0,3);case q1.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case q1.EntityStart:return 0}}};function X1(e,t,n,r){let i=(t&V1.BRANCH_LENGTH)>>7,a=t&V1.JUMP_TABLE;if(i===0)return a!==0&&r===a?n:-1;if(a){let t=r-a;return t<0||t>=i?-1:e[n+t]-1}let o=i+1>>1,s=0,c=i-1;for(;s<=c;){let t=s+c>>>1,i=e[n+(t>>1)]>>(t&1)*8&255;if(i<r)s=t+1;else if(i>r)c=t-1;else return e[n+o+t]}return-1}var q;(function(e){e[e.Tab=9]=`Tab`,e[e.NewLine=10]=`NewLine`,e[e.FormFeed=12]=`FormFeed`,e[e.CarriageReturn=13]=`CarriageReturn`,e[e.Space=32]=`Space`,e[e.ExclamationMark=33]=`ExclamationMark`,e[e.Number=35]=`Number`,e[e.Amp=38]=`Amp`,e[e.SingleQuote=39]=`SingleQuote`,e[e.DoubleQuote=34]=`DoubleQuote`,e[e.Dash=45]=`Dash`,e[e.Slash=47]=`Slash`,e[e.Zero=48]=`Zero`,e[e.Nine=57]=`Nine`,e[e.Semi=59]=`Semi`,e[e.Lt=60]=`Lt`,e[e.Eq=61]=`Eq`,e[e.Gt=62]=`Gt`,e[e.Questionmark=63]=`Questionmark`,e[e.UpperA=65]=`UpperA`,e[e.LowerA=97]=`LowerA`,e[e.UpperF=70]=`UpperF`,e[e.LowerF=102]=`LowerF`,e[e.UpperZ=90]=`UpperZ`,e[e.LowerZ=122]=`LowerZ`,e[e.LowerX=120]=`LowerX`,e[e.OpeningSquareBracket=91]=`OpeningSquareBracket`})(q||={});var J;(function(e){e[e.Text=1]=`Text`,e[e.BeforeTagName=2]=`BeforeTagName`,e[e.InTagName=3]=`InTagName`,e[e.InSelfClosingTag=4]=`InSelfClosingTag`,e[e.BeforeClosingTagName=5]=`BeforeClosingTagName`,e[e.InClosingTagName=6]=`InClosingTagName`,e[e.AfterClosingTagName=7]=`AfterClosingTagName`,e[e.BeforeAttributeName=8]=`BeforeAttributeName`,e[e.InAttributeName=9]=`InAttributeName`,e[e.AfterAttributeName=10]=`AfterAttributeName`,e[e.BeforeAttributeValue=11]=`BeforeAttributeValue`,e[e.InAttributeValueDq=12]=`InAttributeValueDq`,e[e.InAttributeValueSq=13]=`InAttributeValueSq`,e[e.InAttributeValueNq=14]=`InAttributeValueNq`,e[e.BeforeDeclaration=15]=`BeforeDeclaration`,e[e.InDeclaration=16]=`InDeclaration`,e[e.InProcessingInstruction=17]=`InProcessingInstruction`,e[e.BeforeComment=18]=`BeforeComment`,e[e.CDATASequence=19]=`CDATASequence`,e[e.InSpecialComment=20]=`InSpecialComment`,e[e.InCommentLike=21]=`InCommentLike`,e[e.BeforeSpecialS=22]=`BeforeSpecialS`,e[e.BeforeSpecialT=23]=`BeforeSpecialT`,e[e.SpecialStartSequence=24]=`SpecialStartSequence`,e[e.InSpecialTag=25]=`InSpecialTag`,e[e.InEntity=26]=`InEntity`})(J||={});function Z1(e){return e===q.Space||e===q.NewLine||e===q.Tab||e===q.FormFeed||e===q.CarriageReturn}function Q1(e){return e===q.Slash||e===q.Gt||Z1(e)}function $1(e){return e>=q.LowerA&&e<=q.LowerZ||e>=q.UpperA&&e<=q.UpperZ}var e0;(function(e){e[e.NoValue=0]=`NoValue`,e[e.Unquoted=1]=`Unquoted`,e[e.Single=2]=`Single`,e[e.Double=3]=`Double`})(e0||={});const t0={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97]),XmpEnd:new Uint8Array([60,47,120,109,112])};var n0=class{constructor({xmlMode:e=!1,decodeEntities:t=!0},n){this.cbs=n,this.state=J.Text,this.buffer=``,this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=J.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=e,this.decodeEntities=t,this.entityDecoder=new Y1(e?B1:z1,(e,t)=>this.emitCodePoint(e,t))}reset(){this.state=J.Text,this.buffer=``,this.sectionStart=0,this.index=0,this.baseState=J.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(e){this.offset+=this.buffer.length,this.buffer=e,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(e){e===q.Lt||!this.decodeEntities&&this.fastForwardTo(q.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=J.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&e===q.Amp&&this.startEntity()}stateSpecialStartSequence(e){let t=this.sequenceIndex===this.currentSequence.length;if(!(t?Q1(e):(e|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!t){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=J.InTagName,this.stateInTagName(e)}stateInSpecialTag(e){if(this.sequenceIndex===this.currentSequence.length){if(e===q.Gt||Z1(e)){let t=this.index-this.currentSequence.length;if(this.sectionStart<t){let e=this.index;this.index=t,this.cbs.ontext(this.sectionStart,t),this.index=e}this.isSpecial=!1,this.sectionStart=t+2,this.stateInClosingTagName(e);return}this.sequenceIndex=0}(e|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===t0.TitleEnd?this.decodeEntities&&e===q.Amp&&this.startEntity():this.fastForwardTo(q.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=Number(e===q.Lt)}stateCDATASequence(e){e===t0.Cdata[this.sequenceIndex]?++this.sequenceIndex===t0.Cdata.length&&(this.state=J.InCommentLike,this.currentSequence=t0.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=J.InDeclaration,this.stateInDeclaration(e))}fastForwardTo(e){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===e)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(e){e===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===t0.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=J.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):e!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(e){return this.xmlMode?!Q1(e):$1(e)}startSpecial(e,t){this.isSpecial=!0,this.currentSequence=e,this.sequenceIndex=t,this.state=J.SpecialStartSequence}stateBeforeTagName(e){if(e===q.ExclamationMark)this.state=J.BeforeDeclaration,this.sectionStart=this.index+1;else if(e===q.Questionmark)this.state=J.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(e)){let t=e|32;this.sectionStart=this.index,this.xmlMode?this.state=J.InTagName:t===t0.ScriptEnd[2]?this.state=J.BeforeSpecialS:t===t0.TitleEnd[2]||t===t0.XmpEnd[2]?this.state=J.BeforeSpecialT:this.state=J.InTagName}else e===q.Slash?this.state=J.BeforeClosingTagName:(this.state=J.Text,this.stateText(e))}stateInTagName(e){Q1(e)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=J.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateBeforeClosingTagName(e){Z1(e)||(e===q.Gt?this.state=J.Text:(this.state=this.isTagStartChar(e)?J.InClosingTagName:J.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(e){(e===q.Gt||Z1(e))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=J.AfterClosingTagName,this.stateAfterClosingTagName(e))}stateAfterClosingTagName(e){(e===q.Gt||this.fastForwardTo(q.Gt))&&(this.state=J.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(e){e===q.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=J.InSpecialTag,this.sequenceIndex=0):this.state=J.Text,this.sectionStart=this.index+1):e===q.Slash?this.state=J.InSelfClosingTag:Z1(e)||(this.state=J.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(e){e===q.Gt?(this.cbs.onselfclosingtag(this.index),this.state=J.Text,this.sectionStart=this.index+1,this.isSpecial=!1):Z1(e)||(this.state=J.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateInAttributeName(e){(e===q.Eq||Q1(e))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=J.AfterAttributeName,this.stateAfterAttributeName(e))}stateAfterAttributeName(e){e===q.Eq?this.state=J.BeforeAttributeValue:e===q.Slash||e===q.Gt?(this.cbs.onattribend(e0.NoValue,this.sectionStart),this.sectionStart=-1,this.state=J.BeforeAttributeName,this.stateBeforeAttributeName(e)):Z1(e)||(this.cbs.onattribend(e0.NoValue,this.sectionStart),this.state=J.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(e){e===q.DoubleQuote?(this.state=J.InAttributeValueDq,this.sectionStart=this.index+1):e===q.SingleQuote?(this.state=J.InAttributeValueSq,this.sectionStart=this.index+1):Z1(e)||(this.sectionStart=this.index,this.state=J.InAttributeValueNq,this.stateInAttributeValueNoQuotes(e))}handleInAttributeValue(e,t){e===t||!this.decodeEntities&&this.fastForwardTo(t)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(t===q.DoubleQuote?e0.Double:e0.Single,this.index+1),this.state=J.BeforeAttributeName):this.decodeEntities&&e===q.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(e){this.handleInAttributeValue(e,q.DoubleQuote)}stateInAttributeValueSingleQuotes(e){this.handleInAttributeValue(e,q.SingleQuote)}stateInAttributeValueNoQuotes(e){Z1(e)||e===q.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(e0.Unquoted,this.index),this.state=J.BeforeAttributeName,this.stateBeforeAttributeName(e)):this.decodeEntities&&e===q.Amp&&this.startEntity()}stateBeforeDeclaration(e){e===q.OpeningSquareBracket?(this.state=J.CDATASequence,this.sequenceIndex=0):this.state=e===q.Dash?J.BeforeComment:J.InDeclaration}stateInDeclaration(e){(e===q.Gt||this.fastForwardTo(q.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=J.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(e){(e===q.Gt||this.fastForwardTo(q.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=J.Text,this.sectionStart=this.index+1)}stateBeforeComment(e){e===q.Dash?(this.state=J.InCommentLike,this.currentSequence=t0.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=J.InDeclaration}stateInSpecialComment(e){(e===q.Gt||this.fastForwardTo(q.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=J.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(e){let t=e|32;t===t0.ScriptEnd[3]?this.startSpecial(t0.ScriptEnd,4):t===t0.StyleEnd[3]?this.startSpecial(t0.StyleEnd,4):(this.state=J.InTagName,this.stateInTagName(e))}stateBeforeSpecialT(e){switch(e|32){case t0.TitleEnd[3]:this.startSpecial(t0.TitleEnd,4);break;case t0.TextareaEnd[3]:this.startSpecial(t0.TextareaEnd,4);break;case t0.XmpEnd[3]:this.startSpecial(t0.XmpEnd,4);break;default:this.state=J.InTagName,this.stateInTagName(e)}}startEntity(){this.baseState=this.state,this.state=J.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?J1.Strict:this.baseState===J.Text||this.baseState===J.InSpecialTag?J1.Legacy:J1.Attribute)}stateInEntity(){let e=this.index-this.offset,t=this.entityDecoder.write(this.buffer,e);if(t>=0)this.state=this.baseState,t===0&&--this.index;else{if(e<this.buffer.length&&this.buffer.charCodeAt(e)===q.Amp){this.state=this.baseState,--this.index;return}this.index=this.offset+this.buffer.length-1}}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===J.Text||this.state===J.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===J.InAttributeValueDq||this.state===J.InAttributeValueSq||this.state===J.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){let e=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case J.Text:this.stateText(e);break;case J.SpecialStartSequence:this.stateSpecialStartSequence(e);break;case J.InSpecialTag:this.stateInSpecialTag(e);break;case J.CDATASequence:this.stateCDATASequence(e);break;case J.InAttributeValueDq:this.stateInAttributeValueDoubleQuotes(e);break;case J.InAttributeName:this.stateInAttributeName(e);break;case J.InCommentLike:this.stateInCommentLike(e);break;case J.InSpecialComment:this.stateInSpecialComment(e);break;case J.BeforeAttributeName:this.stateBeforeAttributeName(e);break;case J.InTagName:this.stateInTagName(e);break;case J.InClosingTagName:this.stateInClosingTagName(e);break;case J.BeforeTagName:this.stateBeforeTagName(e);break;case J.AfterAttributeName:this.stateAfterAttributeName(e);break;case J.InAttributeValueSq:this.stateInAttributeValueSingleQuotes(e);break;case J.BeforeAttributeValue:this.stateBeforeAttributeValue(e);break;case J.BeforeClosingTagName:this.stateBeforeClosingTagName(e);break;case J.AfterClosingTagName:this.stateAfterClosingTagName(e);break;case J.BeforeSpecialS:this.stateBeforeSpecialS(e);break;case J.BeforeSpecialT:this.stateBeforeSpecialT(e);break;case J.InAttributeValueNq:this.stateInAttributeValueNoQuotes(e);break;case J.InSelfClosingTag:this.stateInSelfClosingTag(e);break;case J.InDeclaration:this.stateInDeclaration(e);break;case J.BeforeDeclaration:this.stateBeforeDeclaration(e);break;case J.BeforeComment:this.stateBeforeComment(e);break;case J.InProcessingInstruction:this.stateInProcessingInstruction(e);break;case J.InEntity:this.stateInEntity();break}this.index++}this.cleanup()}finish(){this.state===J.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){let e=this.buffer.length+this.offset;this.sectionStart>=e||(this.state===J.InCommentLike?this.currentSequence===t0.CdataEnd?this.cbs.oncdata(this.sectionStart,e,0):this.cbs.oncomment(this.sectionStart,e,0):this.state===J.InTagName||this.state===J.BeforeAttributeName||this.state===J.BeforeAttributeValue||this.state===J.AfterAttributeName||this.state===J.InAttributeName||this.state===J.InAttributeValueSq||this.state===J.InAttributeValueDq||this.state===J.InAttributeValueNq||this.state===J.InClosingTagName||this.cbs.ontext(this.sectionStart,e))}emitCodePoint(e,t){this.baseState!==J.Text&&this.baseState!==J.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.onattribentity(e)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.ontextentity(e,this.sectionStart))}};const r0=new Set([`input`,`option`,`optgroup`,`select`,`button`,`datalist`,`textarea`]),i0=new Set([`p`]),a0=new Set([`thead`,`tbody`]),o0=new Set([`dd`,`dt`]),s0=new Set([`rt`,`rp`]),c0=new Map([[`tr`,new Set([`tr`,`th`,`td`])],[`th`,new Set([`th`])],[`td`,new Set([`thead`,`th`,`td`])],[`body`,new Set([`head`,`link`,`script`])],[`li`,new Set([`li`])],[`p`,i0],[`h1`,i0],[`h2`,i0],[`h3`,i0],[`h4`,i0],[`h5`,i0],[`h6`,i0],[`select`,r0],[`input`,r0],[`output`,r0],[`button`,r0],[`datalist`,r0],[`textarea`,r0],[`option`,new Set([`option`])],[`optgroup`,new Set([`optgroup`,`option`])],[`dd`,o0],[`dt`,o0],[`address`,i0],[`article`,i0],[`aside`,i0],[`blockquote`,i0],[`details`,i0],[`div`,i0],[`dl`,i0],[`fieldset`,i0],[`figcaption`,i0],[`figure`,i0],[`footer`,i0],[`form`,i0],[`header`,i0],[`hr`,i0],[`main`,i0],[`nav`,i0],[`ol`,i0],[`pre`,i0],[`section`,i0],[`table`,i0],[`ul`,i0],[`rt`,s0],[`rp`,s0],[`tbody`,a0],[`tfoot`,a0]]),l0=new Set([`area`,`base`,`basefont`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`img`,`input`,`isindex`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),u0=new Set([`math`,`svg`]),d0=new Set([`mi`,`mo`,`mn`,`ms`,`mtext`,`annotation-xml`,`foreignobject`,`desc`,`title`]),f0=/\s|\//;var p0=class{constructor(e,t={}){var n,r;this.options=t,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname=``,this.attribname=``,this.attribvalue=``,this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=e??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=t.lowerCaseTags??this.htmlMode,this.lowerCaseAttributeNames=t.lowerCaseAttributeNames??this.htmlMode,this.recognizeSelfClosing=t.recognizeSelfClosing??!this.htmlMode,this.tokenizer=new(t.Tokenizer??n0)(this.options,this),this.foreignContext=[!this.htmlMode],(r=(n=this.cbs).onparserinit)==null||r.call(n,this)}ontext(e,t){var n,r;let i=this.getSlice(e,t);this.endIndex=t-1,(r=(n=this.cbs).ontext)==null||r.call(n,i),this.startIndex=t}ontextentity(e,t){var n,r;this.endIndex=t-1,(r=(n=this.cbs).ontext)==null||r.call(n,I1(e)),this.startIndex=t}isVoidElement(e){return this.htmlMode&&l0.has(e)}onopentagname(e,t){this.endIndex=t;let n=this.getSlice(e,t);this.lowerCaseTagNames&&(n=n.toLowerCase()),this.emitOpenTag(n)}emitOpenTag(e){var t,n,r,i;this.openTagStart=this.startIndex,this.tagname=e;let a=this.htmlMode&&c0.get(e);if(a)for(;this.stack.length>0&&a.has(this.stack[0]);){let e=this.stack.shift();(n=(t=this.cbs).onclosetag)==null||n.call(t,e,!0)}this.isVoidElement(e)||(this.stack.unshift(e),this.htmlMode&&(u0.has(e)?this.foreignContext.unshift(!0):d0.has(e)&&this.foreignContext.unshift(!1))),(i=(r=this.cbs).onopentagname)==null||i.call(r,e),this.cbs.onopentag&&(this.attribs={})}endOpenTag(e){var t,n;this.startIndex=this.openTagStart,this.attribs&&=((n=(t=this.cbs).onopentag)==null||n.call(t,this.tagname,this.attribs,e),null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=``}onopentagend(e){this.endIndex=e,this.endOpenTag(!1),this.startIndex=e+1}onclosetag(e,t){var n,r,i,a,o,s,c,l;this.endIndex=t;let u=this.getSlice(e,t);if(this.lowerCaseTagNames&&(u=u.toLowerCase()),this.htmlMode&&(u0.has(u)||d0.has(u))&&this.foreignContext.shift(),this.isVoidElement(u))this.htmlMode&&u===`br`&&((a=(i=this.cbs).onopentagname)==null||a.call(i,`br`),(s=(o=this.cbs).onopentag)==null||s.call(o,`br`,{},!0),(l=(c=this.cbs).onclosetag)==null||l.call(c,`br`,!1));else{let e=this.stack.indexOf(u);if(e!==-1)for(let t=0;t<=e;t++){let i=this.stack.shift();(r=(n=this.cbs).onclosetag)==null||r.call(n,i,t!==e)}else this.htmlMode&&u===`p`&&(this.emitOpenTag(`p`),this.closeCurrentTag(!0))}this.startIndex=t+1}onselfclosingtag(e){this.endIndex=e,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=e+1):this.onopentagend(e)}closeCurrentTag(e){var t,n;let r=this.tagname;this.endOpenTag(e),this.stack[0]===r&&((n=(t=this.cbs).onclosetag)==null||n.call(t,r,!e),this.stack.shift())}onattribname(e,t){this.startIndex=e;let n=this.getSlice(e,t);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n}onattribdata(e,t){this.attribvalue+=this.getSlice(e,t)}onattribentity(e){this.attribvalue+=I1(e)}onattribend(e,t){var n,r;this.endIndex=t,(r=(n=this.cbs).onattribute)==null||r.call(n,this.attribname,this.attribvalue,e===e0.Double?`"`:e===e0.Single?`'`:e===e0.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=``}getInstructionName(e){let t=e.search(f0),n=t<0?e:e.substr(0,t);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n}ondeclaration(e,t){this.endIndex=t;let n=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){let e=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${e}`,`!${n}`)}this.startIndex=t+1}onprocessinginstruction(e,t){this.endIndex=t;let n=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){let e=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${e}`,`?${n}`)}this.startIndex=t+1}oncomment(e,t,n){var r,i,a,o;this.endIndex=t,(i=(r=this.cbs).oncomment)==null||i.call(r,this.getSlice(e,t-n)),(o=(a=this.cbs).oncommentend)==null||o.call(a),this.startIndex=t+1}oncdata(e,t,n){var r,i,a,o,s,c,l,u,d,f;this.endIndex=t;let p=this.getSlice(e,t-n);!this.htmlMode||this.options.recognizeCDATA?((i=(r=this.cbs).oncdatastart)==null||i.call(r),(o=(a=this.cbs).ontext)==null||o.call(a,p),(c=(s=this.cbs).oncdataend)==null||c.call(s)):((u=(l=this.cbs).oncomment)==null||u.call(l,`[CDATA[${p}]]`),(f=(d=this.cbs).oncommentend)==null||f.call(d)),this.startIndex=t+1}onend(){var e,t;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let e=0;e<this.stack.length;e++)this.cbs.onclosetag(this.stack[e],!0)}(t=(e=this.cbs).onend)==null||t.call(e)}reset(){var e,t,n,r;(t=(e=this.cbs).onreset)==null||t.call(e),this.tokenizer.reset(),this.tagname=``,this.attribname=``,this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(r=(n=this.cbs).onparserinit)==null||r.call(n,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(e){this.reset(),this.end(e)}getSlice(e,t){for(;e-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();let n=this.buffers[0].slice(e-this.bufferOffset,t-this.bufferOffset);for(;t-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,t-this.bufferOffset);return n}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(e){var t,n;if(this.ended){(n=(t=this.cbs).onerror)==null||n.call(t,Error(`.write() after done!`));return}this.buffers.push(e),this.tokenizer.running&&(this.tokenizer.write(e),this.writeIndex++)}end(e){var t,n;if(this.ended){(n=(t=this.cbs).onerror)==null||n.call(t,Error(`.end() after done!`));return}e&&this.write(e),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(e){this.write(e)}done(e){this.end(e)}},m0=c({CDATA:()=>w0,Comment:()=>b0,Directive:()=>y0,Doctype:()=>T0,ElementType:()=>h0,Root:()=>_0,Script:()=>x0,Style:()=>S0,Tag:()=>C0,Text:()=>v0,isTag:()=>g0}),h0;(function(e){e.Root=`root`,e.Text=`text`,e.Directive=`directive`,e.Comment=`comment`,e.Script=`script`,e.Style=`style`,e.Tag=`tag`,e.CDATA=`cdata`,e.Doctype=`doctype`})(h0||={});function g0(e){return e.type===h0.Tag||e.type===h0.Script||e.type===h0.Style}const _0=h0.Root,v0=h0.Text,y0=h0.Directive,b0=h0.Comment,x0=h0.Script,S0=h0.Style,C0=h0.Tag,w0=h0.CDATA,T0=h0.Doctype;var E0=class{constructor(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}get parentNode(){return this.parent}set parentNode(e){this.parent=e}get previousSibling(){return this.prev}set previousSibling(e){this.prev=e}get nextSibling(){return this.next}set nextSibling(e){this.next=e}cloneNode(e=!1){return H0(this,e)}},D0=class extends E0{constructor(e){super(),this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e}},O0=class extends D0{constructor(){super(...arguments),this.type=h0.Text}get nodeType(){return 3}},k0=class extends D0{constructor(){super(...arguments),this.type=h0.Comment}get nodeType(){return 8}},A0=class extends D0{constructor(e,t){super(t),this.name=e,this.type=h0.Directive}get nodeType(){return 1}},j0=class extends E0{constructor(e){super(),this.children=e}get firstChild(){return this.children[0]??null}get lastChild(){return this.children.length>0?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(e){this.children=e}},M0=class extends j0{constructor(){super(...arguments),this.type=h0.CDATA}get nodeType(){return 4}},N0=class extends j0{constructor(){super(...arguments),this.type=h0.Root}get nodeType(){return 9}},P0=class extends j0{constructor(e,t,n=[],r=e===`script`?h0.Script:e===`style`?h0.Style:h0.Tag){super(n),this.name=e,this.attribs=t,this.type=r}get nodeType(){return 1}get tagName(){return this.name}set tagName(e){this.name=e}get attributes(){return Object.keys(this.attribs).map(e=>({name:e,value:this.attribs[e],namespace:this[`x-attribsNamespace`]?.[e],prefix:this[`x-attribsPrefix`]?.[e]}))}};function F0(e){return g0(e)}function I0(e){return e.type===h0.CDATA}function L0(e){return e.type===h0.Text}function R0(e){return e.type===h0.Comment}function z0(e){return e.type===h0.Directive}function B0(e){return e.type===h0.Root}function V0(e){return Object.prototype.hasOwnProperty.call(e,`children`)}function H0(e,t=!1){let n;if(L0(e))n=new O0(e.data);else if(R0(e))n=new k0(e.data);else if(F0(e)){let r=t?U0(e.children):[],i=new P0(e.name,{...e.attribs},r);r.forEach(e=>e.parent=i),e.namespace!=null&&(i.namespace=e.namespace),e[`x-attribsNamespace`]&&(i[`x-attribsNamespace`]={...e[`x-attribsNamespace`]}),e[`x-attribsPrefix`]&&(i[`x-attribsPrefix`]={...e[`x-attribsPrefix`]}),n=i}else if(I0(e)){let r=t?U0(e.children):[],i=new M0(r);r.forEach(e=>e.parent=i),n=i}else if(B0(e)){let r=t?U0(e.children):[],i=new N0(r);r.forEach(e=>e.parent=i),e[`x-mode`]&&(i[`x-mode`]=e[`x-mode`]),n=i}else if(z0(e)){let t=new A0(e.name,e.data);e[`x-name`]!=null&&(t[`x-name`]=e[`x-name`],t[`x-publicId`]=e[`x-publicId`],t[`x-systemId`]=e[`x-systemId`]),n=t}else throw Error(`Not implemented yet: ${e.type}`);return n.startIndex=e.startIndex,n.endIndex=e.endIndex,e.sourceCodeLocation!=null&&(n.sourceCodeLocation=e.sourceCodeLocation),n}function U0(e){let t=e.map(e=>H0(e,!0));for(let e=1;e<t.length;e++)t[e].prev=t[e-1],t[e-1].next=t[e];return t}const W0={withStartIndices:!1,withEndIndices:!1,xmlMode:!1};var G0=class{constructor(e,t,n){this.dom=[],this.root=new N0(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof t==`function`&&(n=t,t=W0),typeof e==`object`&&(t=e,e=void 0),this.callback=e??null,this.options=t??W0,this.elementCB=n??null}onparserinit(e){this.parser=e}onreset(){this.dom=[],this.root=new N0(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null}onend(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))}onerror(e){this.handleCallback(e)}onclosetag(){this.lastNode=null;let e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)}onopentag(e,t){let n=new P0(e,t,void 0,this.options.xmlMode?h0.Tag:void 0);this.addNode(n),this.tagStack.push(n)}ontext(e){let{lastNode:t}=this;if(t&&t.type===h0.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{let t=new O0(e);this.addNode(t),this.lastNode=t}}oncomment(e){if(this.lastNode&&this.lastNode.type===h0.Comment){this.lastNode.data+=e;return}let t=new k0(e);this.addNode(t),this.lastNode=t}oncommentend(){this.lastNode=null}oncdatastart(){let e=new O0(``),t=new M0([e]);this.addNode(t),e.parent=t,this.lastNode=e}oncdataend(){this.lastNode=null}onprocessinginstruction(e,t){let n=new A0(e,t);this.addNode(n)}handleCallback(e){if(typeof this.callback==`function`)this.callback(e,this.dom);else if(e)throw e}addNode(e){let t=this.tagStack[this.tagStack.length-1],n=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),n&&(e.prev=n,n.next=e),e.parent=t,this.lastNode=null}};const K0=/["&'<>$\x80-\uFFFF]/g,q0=new Map([[34,`&quot;`],[38,`&amp;`],[39,`&apos;`],[60,`&lt;`],[62,`&gt;`]]),J0=String.prototype.codePointAt==null?(e,t)=>(e.charCodeAt(t)&64512)==55296?(e.charCodeAt(t)-55296)*1024+e.charCodeAt(t+1)-56320+65536:e.charCodeAt(t):(e,t)=>e.codePointAt(t);function Y0(e){let t=``,n=0,r;for(;(r=K0.exec(e))!==null;){let i=r.index,a=e.charCodeAt(i),o=q0.get(a);o===void 0?(t+=`${e.substring(n,i)}&#x${J0(e,i).toString(16)};`,n=K0.lastIndex+=Number((a&64512)==55296)):(t+=e.substring(n,i)+o,n=i+1)}return t+e.substr(n)}function X0(e,t){return function(n){let r,i=0,a=``;for(;r=e.exec(n);)i!==r.index&&(a+=n.substring(i,r.index)),a+=t.get(r[0].charCodeAt(0)),i=r.index+1;return a+n.substring(i)}}const Z0=X0(/["&\u00A0]/g,new Map([[34,`&quot;`],[38,`&amp;`],[160,`&nbsp;`]])),Q0=X0(/[&<>\u00A0]/g,new Map([[38,`&amp;`],[60,`&lt;`],[62,`&gt;`],[160,`&nbsp;`]])),$0=new Map(`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.textPath`.split(`.`).map(e=>[e.toLowerCase(),e])),e2=new Map(`definitionURL.attributeName.attributeType.baseFrequency.baseProfile.calcMode.clipPathUnits.diffuseConstant.edgeMode.filterUnits.glyphRef.gradientTransform.gradientUnits.kernelMatrix.kernelUnitLength.keyPoints.keySplines.keyTimes.lengthAdjust.limitingConeAngle.markerHeight.markerUnits.markerWidth.maskContentUnits.maskUnits.numOctaves.pathLength.patternContentUnits.patternTransform.patternUnits.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.refX.refY.repeatCount.repeatDur.requiredExtensions.requiredFeatures.specularConstant.specularExponent.spreadMethod.startOffset.stdDeviation.stitchTiles.surfaceScale.systemLanguage.tableValues.targetX.targetY.textLength.viewBox.viewTarget.xChannelSelector.yChannelSelector.zoomAndPan`.split(`.`).map(e=>[e.toLowerCase(),e])),t2=new Set([`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`]);function n2(e){return e.replace(/"/g,`&quot;`)}function r2(e,t){if(!e)return;let n=(t.encodeEntities??t.decodeEntities)===!1?n2:t.xmlMode||t.encodeEntities!==`utf8`?Y0:Z0;return Object.keys(e).map(r=>{let i=e[r]??``;return t.xmlMode===`foreign`&&(r=e2.get(r)??r),!t.emptyAttrs&&!t.xmlMode&&i===``?r:`${r}="${n(i)}"`}).join(` `)}const i2=new Set([`area`,`base`,`basefont`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`img`,`input`,`isindex`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function a2(e,t={}){let n=`length`in e?e:[e],r=``;for(let e=0;e<n.length;e++)r+=o2(n[e],t);return r}function o2(e,t){switch(e.type){case _0:return a2(e.children,t);case T0:case y0:return u2(e);case b0:return p2(e);case w0:return f2(e);case x0:case S0:case C0:return l2(e,t);case v0:return d2(e,t)}}const s2=new Set([`mi`,`mo`,`mn`,`ms`,`mtext`,`annotation-xml`,`foreignObject`,`desc`,`title`]),c2=new Set([`svg`,`math`]);function l2(e,t){t.xmlMode===`foreign`&&(e.name=$0.get(e.name)??e.name,e.parent&&s2.has(e.parent.name)&&(t={...t,xmlMode:!1})),!t.xmlMode&&c2.has(e.name)&&(t={...t,xmlMode:`foreign`});let n=`<${e.name}`,r=r2(e.attribs,t);return r&&(n+=` ${r}`),e.children.length===0&&(t.xmlMode?t.selfClosingTags!==!1:t.selfClosingTags&&i2.has(e.name))?(t.xmlMode||(n+=` `),n+=`/>`):(n+=`>`,e.children.length>0&&(n+=a2(e.children,t)),(t.xmlMode||!i2.has(e.name))&&(n+=`</${e.name}>`)),n}function u2(e){return`<${e.data}>`}function d2(e,t){let n=e.data||``;return(t.encodeEntities??t.decodeEntities)!==!1&&!(!t.xmlMode&&e.parent&&t2.has(e.parent.name))&&(n=t.xmlMode||t.encodeEntities!==`utf8`?Y0(n):Q0(n)),n}function f2(e){return`<![CDATA[${e.children[0].data}]]>`}function p2(e){return`<!--${e.data}-->`}function m2(e,t){return a2(e,t)}function h2(e,t){return V0(e)?e.children.map(e=>m2(e,t)).join(``):``}function g2(e){return Array.isArray(e)?e.map(g2).join(``):F0(e)?e.name===`br`?`
1780
+ `:g2(e.children):I0(e)?g2(e.children):L0(e)?e.data:``}function _2(e){return Array.isArray(e)?e.map(_2).join(``):V0(e)&&!R0(e)?_2(e.children):L0(e)?e.data:``}function v2(e){return Array.isArray(e)?e.map(v2).join(``):V0(e)&&(e.type===h0.Tag||I0(e))?v2(e.children):L0(e)?e.data:``}function y2(e){return V0(e)?e.children:[]}function b2(e){return e.parent||null}function x2(e){let t=b2(e);if(t!=null)return y2(t);let n=[e],{prev:r,next:i}=e;for(;r!=null;)n.unshift(r),{prev:r}=r;for(;i!=null;)n.push(i),{next:i}=i;return n}function S2(e,t){return e.attribs?.[t]}function C2(e,t){return e.attribs!=null&&Object.prototype.hasOwnProperty.call(e.attribs,t)&&e.attribs[t]!=null}function w2(e){return e.name}function T2(e){let{next:t}=e;for(;t!==null&&!F0(t);)({next:t}=t);return t}function E2(e){let{prev:t}=e;for(;t!==null&&!F0(t);)({prev:t}=t);return t}function D2(e){if(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.parent){let t=e.parent.children,n=t.lastIndexOf(e);n>=0&&t.splice(n,1)}e.next=null,e.prev=null,e.parent=null}function O2(e,t){let n=t.prev=e.prev;n&&(n.next=t);let r=t.next=e.next;r&&(r.prev=t);let i=t.parent=e.parent;if(i){let n=i.children;n[n.lastIndexOf(e)]=t,e.parent=null}}function k2(e,t){if(D2(t),t.next=null,t.parent=e,e.children.push(t)>1){let n=e.children[e.children.length-2];n.next=t,t.prev=n}else t.prev=null}function A2(e,t){D2(t);let{parent:n}=e,r=e.next;if(t.next=r,t.prev=e,e.next=t,t.parent=n,r){if(r.prev=t,n){let e=n.children;e.splice(e.lastIndexOf(r),0,t)}}else n&&n.children.push(t)}function j2(e,t){if(D2(t),t.parent=e,t.prev=null,e.children.unshift(t)!==1){let n=e.children[1];n.prev=t,t.next=n}else t.next=null}function M2(e,t){D2(t);let{parent:n}=e;if(n){let r=n.children;r.splice(r.indexOf(e),0,t)}e.prev&&(e.prev.next=t),t.parent=n,t.prev=e.prev,t.next=e,e.prev=t}function N2(e,t,n=!0,r=1/0){return P2(e,Array.isArray(t)?t:[t],n,r)}function P2(e,t,n,r){let i=[],a=[Array.isArray(t)?t:[t]],o=[0];for(;;){if(o[0]>=a[0].length){if(o.length===1)return i;a.shift(),o.shift();continue}let t=a[0][o[0]++];if(e(t)&&(i.push(t),--r<=0))return i;n&&V0(t)&&t.children.length>0&&(o.unshift(0),a.unshift(t.children))}}function F2(e,t){return t.find(e)}function I2(e,t,n=!0){let r=Array.isArray(t)?t:[t];for(let t=0;t<r.length;t++){let i=r[t];if(F0(i)&&e(i))return i;if(n&&V0(i)&&i.children.length>0){let t=I2(e,i.children,!0);if(t)return t}}return null}function L2(e,t){return(Array.isArray(t)?t:[t]).some(t=>F0(t)&&e(t)||V0(t)&&L2(e,t.children))}function R2(e,t){let n=[],r=[Array.isArray(t)?t:[t]],i=[0];for(;;){if(i[0]>=r[0].length){if(r.length===1)return n;r.shift(),i.shift();continue}let t=r[0][i[0]++];F0(t)&&e(t)&&n.push(t),V0(t)&&t.children.length>0&&(i.unshift(0),r.unshift(t.children))}}const z2={tag_name(e){return typeof e==`function`?t=>F0(t)&&e(t.name):e===`*`?F0:t=>F0(t)&&t.name===e},tag_type(e){return typeof e==`function`?t=>e(t.type):t=>t.type===e},tag_contains(e){return typeof e==`function`?t=>L0(t)&&e(t.data):t=>L0(t)&&t.data===e}};function B2(e,t){return typeof t==`function`?n=>F0(n)&&t(n.attribs[e]):n=>F0(n)&&n.attribs[e]===t}function V2(e,t){return n=>e(n)||t(n)}function H2(e){let t=Object.keys(e).map(t=>{let n=e[t];return Object.prototype.hasOwnProperty.call(z2,t)?z2[t](n):B2(t,n)});return t.length===0?null:t.reduce(V2)}function U2(e,t){let n=H2(e);return n?n(t):!0}function W2(e,t,n,r=1/0){let i=H2(e);return i?N2(i,t,n,r):[]}function G2(e,t,n=!0){return Array.isArray(t)||(t=[t]),I2(B2(`id`,e),t,n)}function K2(e,t,n=!0,r=1/0){return N2(z2.tag_name(e),t,n,r)}function q2(e,t,n=!0,r=1/0){return N2(B2(`class`,e),t,n,r)}function J2(e,t,n=!0,r=1/0){return N2(z2.tag_type(e),t,n,r)}function Y2(e){let t=e.length;for(;--t>=0;){let n=e[t];if(t>0&&e.lastIndexOf(n,t-1)>=0){e.splice(t,1);continue}for(let r=n.parent;r;r=r.parent)if(e.includes(r)){e.splice(t,1);break}}return e}var X2;(function(e){e[e.DISCONNECTED=1]=`DISCONNECTED`,e[e.PRECEDING=2]=`PRECEDING`,e[e.FOLLOWING=4]=`FOLLOWING`,e[e.CONTAINS=8]=`CONTAINS`,e[e.CONTAINED_BY=16]=`CONTAINED_BY`})(X2||={});function Z2(e,t){let n=[],r=[];if(e===t)return 0;let i=V0(e)?e:e.parent;for(;i;)n.unshift(i),i=i.parent;for(i=V0(t)?t:t.parent;i;)r.unshift(i),i=i.parent;let a=Math.min(n.length,r.length),o=0;for(;o<a&&n[o]===r[o];)o++;if(o===0)return X2.DISCONNECTED;let s=n[o-1],c=s.children,l=n[o],u=r[o];return c.indexOf(l)>c.indexOf(u)?s===t?X2.FOLLOWING|X2.CONTAINED_BY:X2.FOLLOWING:s===e?X2.PRECEDING|X2.CONTAINS:X2.PRECEDING}function Q2(e){return e=e.filter((e,t,n)=>!n.includes(e,t+1)),e.sort((e,t)=>{let n=Z2(e,t);return n&X2.PRECEDING?-1:n&X2.FOLLOWING?1:0}),e}function $2(e){let t=a4(c4,e);return t?t.name===`feed`?e4(t):t4(t):null}function e4(e){let t=e.children,n={type:`atom`,items:K2(`entry`,t).map(e=>{let{children:t}=e,n={media:i4(t)};s4(n,`id`,`id`,t),s4(n,`title`,`title`,t);let r=a4(`link`,t)?.attribs.href;r&&(n.link=r);let i=o4(`summary`,t)||o4(`content`,t);i&&(n.description=i);let a=o4(`updated`,t);return a&&(n.pubDate=new Date(a)),n})};s4(n,`id`,`id`,t),s4(n,`title`,`title`,t);let r=a4(`link`,t)?.attribs.href;r&&(n.link=r),s4(n,`description`,`subtitle`,t);let i=o4(`updated`,t);return i&&(n.updated=new Date(i)),s4(n,`author`,`email`,t,!0),n}function t4(e){let t=a4(`channel`,e.children)?.children??[],n={type:e.name.substr(0,3),id:``,items:K2(`item`,e.children).map(e=>{let{children:t}=e,n={media:i4(t)};s4(n,`id`,`guid`,t),s4(n,`title`,`title`,t),s4(n,`link`,`link`,t),s4(n,`description`,`description`,t);let r=o4(`pubDate`,t)||o4(`dc:date`,t);return r&&(n.pubDate=new Date(r)),n})};s4(n,`title`,`title`,t),s4(n,`link`,`link`,t),s4(n,`description`,`description`,t);let r=o4(`lastBuildDate`,t);return r&&(n.updated=new Date(r)),s4(n,`author`,`managingEditor`,t,!0),n}const n4=[`url`,`type`,`lang`],r4=[`fileSize`,`bitrate`,`framerate`,`samplingrate`,`channels`,`duration`,`height`,`width`];function i4(e){return K2(`media:content`,e).map(e=>{let{attribs:t}=e,n={medium:t.medium,isDefault:!!t.isDefault};for(let e of n4)t[e]&&(n[e]=t[e]);for(let e of r4)t[e]&&(n[e]=parseInt(t[e],10));return t.expression&&(n.expression=t.expression),n})}function a4(e,t){return K2(e,t,!0,1)[0]}function o4(e,t,n=!1){return _2(K2(e,t,n,1)).trim()}function s4(e,t,n,r,i=!1){let a=o4(n,r,i);a&&(e[t]=a)}function c4(e){return e===`rss`||e===`feed`||e===`rdf:RDF`}var l4=c({DocumentPosition:()=>X2,append:()=>A2,appendChild:()=>k2,compareDocumentPosition:()=>Z2,existsOne:()=>L2,filter:()=>N2,find:()=>P2,findAll:()=>R2,findOne:()=>I2,findOneChild:()=>F2,getAttributeValue:()=>S2,getChildren:()=>y2,getElementById:()=>G2,getElements:()=>W2,getElementsByClassName:()=>q2,getElementsByTagName:()=>K2,getElementsByTagType:()=>J2,getFeed:()=>$2,getInnerHTML:()=>h2,getName:()=>w2,getOuterHTML:()=>m2,getParent:()=>b2,getSiblings:()=>x2,getText:()=>g2,hasAttrib:()=>C2,hasChildren:()=>V0,innerText:()=>v2,isCDATA:()=>I0,isComment:()=>R0,isDocument:()=>B0,isTag:()=>F0,isText:()=>L0,nextElementSibling:()=>T2,prepend:()=>M2,prependChild:()=>j2,prevElementSibling:()=>E2,removeElement:()=>D2,removeSubsets:()=>Y2,replaceElement:()=>O2,testElement:()=>U2,textContent:()=>_2,uniqueSort:()=>Q2}),u4=c({DefaultHandler:()=>G0,DomHandler:()=>G0,DomUtils:()=>l4,ElementType:()=>m0,Parser:()=>p0,QuoteType:()=>e0,Tokenizer:()=>n0,createDocumentStream:()=>p4,createDomStream:()=>m4,getFeed:()=>$2,parseDOM:()=>f4,parseDocument:()=>d4,parseFeed:()=>g4});function d4(e,t){let n=new G0(void 0,t);return new p0(n,t).end(e),n.root}function f4(e,t){return d4(e,t).children}function p4(e,t,n){let r=new G0(t=>e(t,r.root),t,n);return new p0(r,t)}function m4(e,t,n){return new p0(new G0(e,t,n),t)}const h4={xmlMode:!0};function g4(e,t=h4){return $2(f4(e,t))}const _4=new Set(`ARTICLE.ASIDE.BLOCKQUOTE.BODY.BR.BUTTON.CANVAS.CAPTION.COL.COLGROUP.DD.DIV.DL.DT.EMBED.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.LI.UL.OL.P`.split(`.`)),v4=`http://www.w3.org/2000/svg`,{assign:y4,create:b4,defineProperties:x4,entries:S4,getOwnPropertyDescriptors:hee,keys:C4,setPrototypeOf:w4}=Object,T4=String,E4=e=>e.nodeType===1?e[G]:e,D4=({ownerDocument:e})=>e[T1].ignoreCase,O4=(e,t)=>{e[K]=t,t[O1]=e},k4=(e,t,n)=>{O4(e,t),O4(E4(t),n)},A4=(e,t,n,r)=>{O4(e,t),O4(E4(n),r)},j4=(e,t,n)=>{O4(e,t),O4(t,n)},M4=({localName:e,ownerDocument:t})=>t[T1].ignoreCase?e.toUpperCase():e,N4=(e,t)=>{e&&(e[K]=t),t&&(t[O1]=e)},P4=(e,t)=>{let n=e.createDocumentFragment(),r=e.createElement(``);r.innerHTML=t;let{firstChild:i,lastChild:a}=r;if(i){A4(n,i,a,n[G]);let e=i;do e.parentNode=n;while(e!==a&&(e=E4(e)[K]))}return n},F4=new WeakMap;let I4=!1;const L4=new WeakMap,R4=new WeakMap,z4=(e,t,n,r)=>{I4&&R4.has(e)&&e.attributeChangedCallback&&e.constructor.observedAttributes.includes(t)&&e.attributeChangedCallback(t,n,r)},B4=(e,t)=>n=>{if(R4.has(n)){let r=R4.get(n);r.connected!==t&&n.isConnected===t&&(r.connected=t,e in n&&n[e]())}},V4=B4(`connectedCallback`,!0),H4=e=>{if(I4){V4(e),F4.has(e)&&(e=F4.get(e).shadowRoot);let{[K]:t,[G]:n}=e;for(;t!==n;)t.nodeType===1&&V4(t),t=t[K]}},U4=B4(`disconnectedCallback`,!1),W4=e=>{if(I4){U4(e),F4.has(e)&&(e=F4.get(e).shadowRoot);let{[K]:t,[G]:n}=e;for(;t!==n;)t.nodeType===1&&U4(t),t=t[K]}};var G4=class{constructor(e){this.ownerDocument=e,this.registry=new Map,this.waiting=new Map,this.active=!1}define(e,t,n={}){let{ownerDocument:r,registry:i,waiting:a}=this;if(i.has(e))throw Error(`unable to redefine `+e);if(L4.has(t))throw Error(`unable to redefine the same class: `+t);this.active=I4=!0;let{extends:o}=n;L4.set(t,{ownerDocument:r,options:{is:o?e:``},localName:o||e});let s=o?t=>t.localName===o&&t.getAttribute(`is`)===e:t=>t.localName===e;if(i.set(e,{Class:t,check:s}),a.has(e)){for(let n of a.get(e))n(t);a.delete(e)}r.querySelectorAll(o?`${o}[is="${e}"]`:e).forEach(this.upgrade,this)}upgrade(e){if(R4.has(e))return;let{ownerDocument:t,registry:n}=this,r=e.getAttribute(`is`)||e.localName;if(n.has(r)){let{Class:i,check:a}=n.get(r);if(a(e)){let{attributes:n,isConnected:a}=e;for(let t of n)e.removeAttributeNode(t);let o=S4(e);for(let[t]of o)delete e[t];w4(e,i.prototype),t[N1]={element:e,values:o},new i(t,r),R4.set(e,{connected:a});for(let t of n)e.setAttributeNode(t);a&&e.connectedCallback&&e.connectedCallback()}}}whenDefined(e){let{registry:t,waiting:n}=this;return new Promise(r=>{t.has(e)?r(t.get(e).Class):(n.has(e)||n.set(e,[]),n.get(e).push(r))})}get(e){let t=this.registry.get(e);return t&&t.Class}getName(e){if(L4.has(e)){let{localName:t}=L4.get(e);return t}return null}};const{Parser:K4}=u4,q4=(e,t,n)=>{let r=e[G];return t.parentNode=e,k4(r[O1],t,r),n&&t.nodeType===1&&H4(t),t},J4=(e,t,n,r,i)=>{n[P1]=r,n.ownerElement=e,j4(t[O1],n,t),n.name===`class`&&(e.className=r),i&&z4(e,n.name,null,r)},Y4=(e,t,n)=>{let{active:r,registry:i}=e[_1],a=e,o=null,s=!1,c=new K4({onprocessinginstruction(t,n){t.toLowerCase()===`!doctype`&&(e.doctype=n.slice(t.length).trim())},onopentag(n,s){let c=!0;if(t){if(o)a=q4(a,e.createElementNS(v4,n),r),a.ownerSVGElement=o,c=!1;else if(n===`svg`||n===`SVG`)o=e.createElementNS(v4,n),a=q4(a,o,r),c=!1;else if(r){let e=n.includes(`-`)?n:s.is||``;if(e&&i.has(e)){let{Class:t}=i.get(e);a=q4(a,new t,r),delete s.is,c=!1}}}c&&(a=q4(a,e.createElement(n),!1));let l=a[G];for(let t of C4(s))J4(a,l,e.createAttribute(t),s[t],r)},oncomment(t){q4(a,e.createComment(t),r)},ontext(t){s?q4(a,e.createCDATASection(t),r):q4(a,e.createTextNode(t),r)},oncdatastart(){s=!0},oncdataend(){s=!1},onclosetag(){t&&a===o&&(o=null),a=a.parentNode}},{lowerCaseAttributeNames:!1,decodeEntities:!0,xmlMode:!t});return c.write(n),c.end(),e},X4=new Map,Z4=(e,t)=>{for(let n of[].concat(e))X4.set(n,t),X4.set(n.toUpperCase(),t)},Q4=({[K]:e,[G]:t},n)=>{for(;e!==t;){switch(e.nodeType){case 2:$4(e,n);break;case 3:case 8:case 4:e3(e,n);break;case 1:r3(e,n),e=E4(e);break;case 10:n3(e,n);break}e=e[K]}let r=n.length-1,i=n[r];typeof i==`number`&&i<0?n[r]+=-1:n.push(-1)},$4=(e,t)=>{t.push(2,e.name);let n=e[P1].trim();n&&t.push(n)},e3=(e,t)=>{let n=e[P1];n.trim()&&t.push(e.nodeType,n)},t3=(e,t)=>{t.push(e.nodeType),Q4(e,t)},n3=({name:e,publicId:t,systemId:n},r)=>{r.push(10,e),t&&r.push(t),n&&r.push(n)},r3=(e,t)=>{t.push(1,e.localName),Q4(e,t)},i3=(e,t,n,r,i,a,o)=>({type:e,target:t,addedNodes:r,removedNodes:i,attributeName:a,oldValue:o,previousSibling:n?.previousSibling||null,nextSibling:n?.nextSibling||null}),a3=(e,t,n,r,i,a)=>{if(!r||r.includes(n)){let{callback:r,records:o,scheduled:s}=e;o.push(i3(`attributes`,t,null,[],[],n,i?a:void 0)),s||(e.scheduled=!0,Promise.resolve().then(()=>{e.scheduled=!1,r(o.splice(0),e)}))}},o3=(e,t,n)=>{let{ownerDocument:r}=e,{active:i,observers:a}=r[E1];if(i){for(let i of a)for(let[a,{childList:o,subtree:s,attributes:c,attributeFilter:l,attributeOldValue:u}]of i.nodes)if(o){if(s&&(a===r||a.contains(e))||!s&&a.children.includes(e)){a3(i,e,t,l,u,n);break}}else if(c&&a===e){a3(i,e,t,l,u,n);break}}},s3=(e,t)=>{let{ownerDocument:n}=e,{active:r,observers:i}=n[E1];if(r){for(let r of i)for(let[i,{subtree:a,childList:o,characterData:s}]of r.nodes)if(o&&(t&&(i===t||a&&i.contains(t))||!t&&(a&&(i===n||i.contains(e))||!a&&i[s?`childNodes`:`children`].includes(e)))){let{callback:n,records:a,scheduled:o}=r;a.push(i3(`childList`,i,e,t?[]:[e],t?[e]:[])),o||(r.scheduled=!0,Promise.resolve().then(()=>{r.scheduled=!1,n(a.splice(0),r)}));break}}};var c3=class{constructor(e){let t=new Set;this.observers=t,this.active=!1,this.class=class{constructor(e){this.callback=e,this.nodes=new Map,this.records=[],this.scheduled=!1}disconnect(){this.records.splice(0),this.nodes.clear(),t.delete(this),e[E1].active=!!t.size}observe(n,r={subtree:!1,childList:!1,attributes:!1,attributeFilter:null,attributeOldValue:!1,characterData:!1}){(`attributeOldValue`in r||`attributeFilter`in r)&&(r.attributes=!0),r.childList=!!r.childList,r.subtree=!!r.subtree,this.nodes.set(n,r),t.add(this),e[E1].active=!0}takeRecords(){return this.records.splice(0)}}}};const l3=new Set(`allowfullscreen.allowpaymentrequest.async.autofocus.autoplay.checked.class.contenteditable.controls.default.defer.disabled.draggable.formnovalidate.hidden.id.ismap.itemscope.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.selected.style.truespeed`.split(`.`)),u3=(e,t)=>{let{[P1]:n,name:r}=t;t.ownerElement=e,j4(e,t,e[K]),r===`class`&&(e.className=n),o3(e,r,null),z4(e,r,null,n)},d3=(e,t)=>{let{[P1]:n,name:r}=t;O4(t[O1],t[K]),t.ownerElement=t[O1]=t[K]=null,r===`class`&&(e[g1]=null),o3(e,r,n),z4(e,r,n,null)},f3={get(e,t){return e.hasAttribute(t)},set(e,t,n){n?e.setAttribute(t,``):e.removeAttribute(t)}},p3={get(e,t){return parseFloat(e.getAttribute(t)||0)},set(e,t,n){e.setAttribute(t,n)}},Y={get(e,t){return e.getAttribute(t)||``},set(e,t,n){e.setAttribute(t,n)}},m3=new WeakMap;function h3(e,t){return typeof t==`function`?t.call(e.target,e):t.handleEvent(e),e._stopImmediatePropagationFlag}function g3({currentTarget:e,target:t}){let n=m3.get(e);if(n&&n.has(this.type)){let r=n.get(this.type);e===t?this.eventPhase=this.AT_TARGET:this.eventPhase=this.BUBBLING_PHASE,this.currentTarget=e,this.target=t;for(let[e,t]of r)if(t&&t.once&&r.delete(e),h3(this,e))break;return delete this.currentTarget,delete this.target,this.cancelBubble}}var _3=class{constructor(){m3.set(this,new Map)}_getParent(){return null}addEventListener(e,t,n){let r=m3.get(this);r.has(e)||r.set(e,new Map),r.get(e).set(t,n)}removeEventListener(e,t){let n=m3.get(this);if(n.has(e)){let r=n.get(e);r.delete(t)&&!r.size&&n.delete(e)}}dispatchEvent(e){let t=this;for(e.eventPhase=e.CAPTURING_PHASE;t;)t.dispatchEvent&&e._path.push({currentTarget:t,target:this}),t=e.bubbles&&t._getParent&&t._getParent();return e._path.some(g3,e),e._path=[],e.eventPhase=e.NONE,!e.defaultPrevented}},v3=class extends Array{item(e){return e<this.length?this[e]:null}};const y3=({parentNode:e})=>{let t=0;for(;e;)t++,e=e.parentNode;return t};var b3=class extends _3{static get ELEMENT_NODE(){return 1}static get ATTRIBUTE_NODE(){return 2}static get TEXT_NODE(){return 3}static get CDATA_SECTION_NODE(){return 4}static get COMMENT_NODE(){return 8}static get DOCUMENT_NODE(){return 9}static get DOCUMENT_FRAGMENT_NODE(){return 11}static get DOCUMENT_TYPE_NODE(){return 10}constructor(e,t,n){super(),this.ownerDocument=e,this.localName=t,this.nodeType=n,this.parentNode=null,this[K]=null,this[O1]=null}get ELEMENT_NODE(){return 1}get ATTRIBUTE_NODE(){return 2}get TEXT_NODE(){return 3}get CDATA_SECTION_NODE(){return 4}get COMMENT_NODE(){return 8}get DOCUMENT_NODE(){return 9}get DOCUMENT_FRAGMENT_NODE(){return 11}get DOCUMENT_TYPE_NODE(){return 10}get baseURI(){let e=this.nodeType===9?this:this.ownerDocument;if(e){let t=e.querySelector(`base`);if(t)return t.getAttribute(`href`);let{location:n}=e.defaultView;if(n)return n.href}return null}get isConnected(){return!1}get nodeName(){return this.localName}get parentElement(){return null}get previousSibling(){return null}get previousElementSibling(){return null}get nextSibling(){return null}get nextElementSibling(){return null}get childNodes(){return new v3}get firstChild(){return null}get lastChild(){return null}get nodeValue(){return null}set nodeValue(e){}get textContent(){return null}set textContent(e){}normalize(){}cloneNode(){return null}contains(){return!1}insertBefore(e,t){return e}appendChild(e){return e}replaceChild(e,t){return t}removeChild(e){return e}toString(){return``}hasChildNodes(){return!!this.lastChild}isSameNode(e){return this===e}compareDocumentPosition(e){let t=0;if(this!==e){let n=y3(this),r=y3(e);if(n<r)t+=4,this.contains(e)&&(t+=16);else if(r<n)t+=2,e.contains(this)&&(t+=8);else if(n&&r){let{childNodes:n}=this.parentNode;n.indexOf(this)<n.indexOf(e)?t+=4:t+=2}(!n||!r)&&(t+=32,t+=1)}return t}isEqualNode(e){if(this===e)return!0;if(this.nodeType===e.nodeType){switch(this.nodeType){case 9:case 11:{let t=this.childNodes,n=e.childNodes;return t.length===n.length&&t.every((e,t)=>e.isEqualNode(n[t]))}}return this.toString()===e.toString()}return!1}_getParent(){return this.parentNode}getRootNode(){let e=this;for(;e.parentNode;)e=e.parentNode;return e}};const{replace:x3}=``,S3=/[<>&\xA0]/g,C3={"\xA0":`&#160;`,"&":`&amp;`,"<":`&lt;`,">":`&gt;`},w3=e=>C3[e],T3=e=>x3.call(e,S3,w3),E3=/"/g;var D3=class e extends b3{constructor(e,t,n=``){super(e,t,2),this.ownerElement=null,this.name=T4(t),this[P1]=T4(n),this[h1]=!1}get value(){return this[P1]}set value(e){let{[P1]:t,name:n,ownerElement:r}=this;this[P1]=T4(e),this[h1]=!0,r&&(o3(r,n,t),z4(r,n,t,this[P1]))}cloneNode(){let{ownerDocument:t,name:n,[P1]:r}=this;return new e(t,n,r)}toString(){let{name:e,[P1]:t}=this;return l3.has(e)&&!t?D4(this)?e:`${e}=""`:`${e}="${(D4(this)?t:T3(t)).replace(E3,`&quot;`)}"`}toJSON(){let e=[];return $4(this,e),e}};const O3=({ownerDocument:e,parentNode:t})=>{for(;t;){if(t===e)return!0;t=t.parentNode||t.host}return!1},k3=({parentNode:e})=>{if(e)switch(e.nodeType){case 9:case 11:return null}return e},A3=({[O1]:e})=>{switch(e?e.nodeType:0){case-1:return e[j1];case 3:case 8:case 4:return e}return null},j3=e=>{let t=E4(e)[K];return t&&(t.nodeType===-1?null:t)},M3=e=>{let t=j3(e);for(;t&&t.nodeType!==1;)t=j3(t);return t},N3=e=>{let t=A3(e);for(;t&&t.nodeType!==1;)t=A3(t);return t},P3=(e,t)=>{let n=e.createDocumentFragment();return n.append(...t),n},F3=(e,t)=>{let{ownerDocument:n,parentNode:r}=e;r&&r.insertBefore(P3(n,t),e)},I3=(e,t)=>{let{ownerDocument:n,parentNode:r}=e;r&&r.insertBefore(P3(n,t),E4(e)[K])},L3=(e,t)=>{let{ownerDocument:n,parentNode:r}=e;r&&(t.includes(e)&&L3(e,[e=e.cloneNode()]),r.insertBefore(P3(n,t),e),e.remove())},R3=(e,t,n)=>{let{parentNode:r,nodeType:i}=t;(e||n)&&(N4(e,n),t[O1]=null,E4(t)[K]=null),r&&(t.parentNode=null,s3(t,r),i===1&&W4(t))};var z3=class extends b3{constructor(e,t,n,r){super(e,t,n),this[P1]=T4(r)}get isConnected(){return O3(this)}get parentElement(){return k3(this)}get previousSibling(){return A3(this)}get nextSibling(){return j3(this)}get previousElementSibling(){return N3(this)}get nextElementSibling(){return M3(this)}before(...e){F3(this,e)}after(...e){I3(this,e)}replaceWith(...e){L3(this,e)}remove(){R3(this[O1],this,this[K])}get data(){return this[P1]}set data(e){this[P1]=T4(e),s3(this,this.parentNode)}get nodeValue(){return this.data}set nodeValue(e){this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}get length(){return this.data.length}substringData(e,t){return this.data.substr(e,t)}appendData(e){this.data+=e}insertData(e,t){let{data:n}=this;this.data=n.slice(0,e)+t+n.slice(e)}deleteData(e,t){let{data:n}=this;this.data=n.slice(0,e)+n.slice(e+t)}replaceData(e,t,n){let{data:r}=this;this.data=r.slice(0,e)+n+r.slice(e+t)}toJSON(){let e=[];return e3(this,e),e}},B3=class e extends z3{constructor(e,t=``){super(e,`#cdatasection`,4,t)}cloneNode(){let{ownerDocument:t,[P1]:n}=this;return new e(t,n)}toString(){return`<![CDATA[${this[P1]}]]>`}},V3=class e extends z3{constructor(e,t=``){super(e,`#comment`,8,t)}cloneNode(){let{ownerDocument:t,[P1]:n}=this;return new e(t,n)}toString(){return`<!--${this[P1]}-->`}},H3=s(((e,t)=>{t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}})),X;(function(e){e.Attribute=`attribute`,e.Pseudo=`pseudo`,e.PseudoElement=`pseudo-element`,e.Tag=`tag`,e.Universal=`universal`,e.Adjacent=`adjacent`,e.Child=`child`,e.Descendant=`descendant`,e.Parent=`parent`,e.Sibling=`sibling`,e.ColumnCombinator=`column-combinator`})(X||={});var U3;(function(e){e.Any=`any`,e.Element=`element`,e.End=`end`,e.Equals=`equals`,e.Exists=`exists`,e.Hyphen=`hyphen`,e.Not=`not`,e.Start=`start`})(U3||={});const W3=/^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,G3=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,K3=new Map([[126,U3.Element],[94,U3.Start],[36,U3.End],[42,U3.Any],[33,U3.Not],[124,U3.Hyphen]]),q3=new Set([`has`,`not`,`matches`,`is`,`where`,`host`,`host-context`]);function J3(e){switch(e.type){case X.Adjacent:case X.Child:case X.Descendant:case X.Parent:case X.Sibling:case X.ColumnCombinator:return!0;default:return!1}}const Y3=new Set([`contains`,`icontains`]);function X3(e,t,n){let r=parseInt(t,16)-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,r&1023|56320)}function Z3(e){return e.replace(G3,X3)}function Q3(e){return e===39||e===34}function $3(e){return e===32||e===9||e===10||e===12||e===13}function e6(e){let t=[],n=t6(t,`${e}`,0);if(n<e.length)throw Error(`Unmatched selector: ${e.slice(n)}`);return t}function t6(e,t,n){let r=[];function i(e){let r=t.slice(n+e).match(W3);if(!r)throw Error(`Expected name, found ${t.slice(n)}`);let[i]=r;return n+=e+i.length,Z3(i)}function a(e){for(n+=e;n<t.length&&$3(t.charCodeAt(n));)n++}function o(){n+=1;let e=n,r=1;for(;r>0&&n<t.length;n++)t.charCodeAt(n)===40&&!s(n)?r++:t.charCodeAt(n)===41&&!s(n)&&r--;if(r)throw Error(`Parenthesis not matched`);return Z3(t.slice(e,n-1))}function s(e){let n=0;for(;t.charCodeAt(--e)===92;)n++;return(n&1)==1}function c(){if(r.length>0&&J3(r[r.length-1]))throw Error(`Did not expect successive traversals.`)}function l(e){if(r.length>0&&r[r.length-1].type===X.Descendant){r[r.length-1].type=e;return}c(),r.push({type:e})}function u(e,t){r.push({type:X.Attribute,name:e,action:t,value:i(1),namespace:null,ignoreCase:`quirks`})}function d(){if(r.length&&r[r.length-1].type===X.Descendant&&r.pop(),r.length===0)throw Error(`Empty sub-selector`);e.push(r)}if(a(0),t.length===n)return n;loop:for(;n<t.length;){let e=t.charCodeAt(n);switch(e){case 32:case 9:case 10:case 12:case 13:(r.length===0||r[0].type!==X.Descendant)&&(c(),r.push({type:X.Descendant})),a(1);break;case 62:l(X.Child),a(1);break;case 60:l(X.Parent),a(1);break;case 126:l(X.Sibling),a(1);break;case 43:l(X.Adjacent),a(1);break;case 46:u(`class`,U3.Element);break;case 35:u(`id`,U3.Equals);break;case 91:{a(1);let e,o=null;t.charCodeAt(n)===124?e=i(1):t.startsWith(`*|`,n)?(o=`*`,e=i(2)):(e=i(0),t.charCodeAt(n)===124&&t.charCodeAt(n+1)!==61&&(o=e,e=i(1))),a(0);let c=U3.Exists,l=K3.get(t.charCodeAt(n));if(l){if(c=l,t.charCodeAt(n+1)!==61)throw Error("Expected `=`");a(2)}else t.charCodeAt(n)===61&&(c=U3.Equals,a(1));let u=``,d=null;if(c!==`exists`){if(Q3(t.charCodeAt(n))){let e=t.charCodeAt(n),r=n+1;for(;r<t.length&&(t.charCodeAt(r)!==e||s(r));)r+=1;if(t.charCodeAt(r)!==e)throw Error(`Attribute value didn't end`);u=Z3(t.slice(n+1,r)),n=r+1}else{let e=n;for(;n<t.length&&(!$3(t.charCodeAt(n))&&t.charCodeAt(n)!==93||s(n));)n+=1;u=Z3(t.slice(e,n))}a(0);let e=t.charCodeAt(n)|32;e===115?(d=!1,a(1)):e===105&&(d=!0,a(1))}if(t.charCodeAt(n)!==93)throw Error(`Attribute selector didn't terminate`);n+=1;let f={type:X.Attribute,name:e,action:c,value:u,namespace:o,ignoreCase:d};r.push(f);break}case 58:{if(t.charCodeAt(n+1)===58){r.push({type:X.PseudoElement,name:i(2).toLowerCase(),data:t.charCodeAt(n)===40?o():null});continue}let e=i(1).toLowerCase(),a=null;if(t.charCodeAt(n)===40)if(q3.has(e)){if(Q3(t.charCodeAt(n+1)))throw Error(`Pseudo-selector ${e} cannot be quoted`);if(a=[],n=t6(a,t,n+1),t.charCodeAt(n)!==41)throw Error(`Missing closing parenthesis in :${e} (${t})`);n+=1}else{if(a=o(),Y3.has(e)){let e=a.charCodeAt(0);e===a.charCodeAt(a.length-1)&&Q3(e)&&(a=a.slice(1,-1))}a=Z3(a)}r.push({type:X.Pseudo,name:e,data:a});break}case 44:d(),r=[],a(1);break;default:{if(t.startsWith(`/*`,n)){let e=t.indexOf(`*/`,n+2);if(e<0)throw Error(`Comment was not terminated`);n=e+2,r.length===0&&a(0);break}let o=null,s;if(e===42)n+=1,s=`*`;else if(e===124){if(s=``,t.charCodeAt(n+1)===124){l(X.ColumnCombinator),a(2);break}}else if(W3.test(t.slice(n)))s=i(0);else break loop;t.charCodeAt(n)===124&&t.charCodeAt(n+1)!==124&&(o=s,t.charCodeAt(n+1)===42?(s=`*`,n+=2):s=i(1)),r.push(s===`*`?{type:X.Universal,namespace:o}:{type:X.Tag,name:s,namespace:o})}}}return d(),n}var Z=u(H3());const n6=new Map([[X.Universal,50],[X.Tag,30],[X.Attribute,1],[X.Pseudo,0]]);function r6(e){return!n6.has(e.type)}const i6=new Map([[U3.Exists,10],[U3.Equals,8],[U3.Not,7],[U3.Start,6],[U3.End,6],[U3.Any,5]]);function a6(e){let t=e.map(o6);for(let n=1;n<e.length;n++){let r=t[n];if(!(r<0))for(let i=n-1;i>=0&&r<t[i];i--){let n=e[i+1];e[i+1]=e[i],e[i]=n,t[i+1]=t[i],t[i]=r}}}function o6(e){let t=n6.get(e.type)??-1;return e.type===X.Attribute?(t=i6.get(e.action)??4,e.action===U3.Equals&&e.name===`id`&&(t=9),e.ignoreCase&&(t>>=1)):e.type===X.Pseudo&&(e.data?e.name===`has`||e.name===`contains`?t=0:Array.isArray(e.data)?(t=Math.min(...e.data.map(e=>Math.min(...e.map(o6)))),t<0&&(t=0)):t=2:t=3),t}const s6=/[-[\]{}()*+?.,\\^$|#\s]/g;function c6(e){return e.replace(s6,`\\$&`)}const l6=new Set(`accept.accept-charset.align.alink.axis.bgcolor.charset.checked.clear.codetype.color.compact.declare.defer.dir.direction.disabled.enctype.face.frame.hreflang.http-equiv.lang.language.link.media.method.multiple.nohref.noresize.noshade.nowrap.readonly.rel.rev.rules.scope.scrolling.selected.shape.target.text.type.valign.valuetype.vlink`.split(`.`));function u6(e,t){return typeof e.ignoreCase==`boolean`?e.ignoreCase:e.ignoreCase===`quirks`?!!t.quirksMode:!t.xmlMode&&l6.has(e.name)}const d6={equals(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t;return u6(t,n)?(a=a.toLowerCase(),t=>{let n=r.getAttributeValue(t,i);return n!=null&&n.length===a.length&&n.toLowerCase()===a&&e(t)}):t=>r.getAttributeValue(t,i)===a&&e(t)},hyphen(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t,o=a.length;return u6(t,n)?(a=a.toLowerCase(),function(t){let n=r.getAttributeValue(t,i);return n!=null&&(n.length===o||n.charAt(o)===`-`)&&n.substr(0,o).toLowerCase()===a&&e(t)}):function(t){let n=r.getAttributeValue(t,i);return n!=null&&(n.length===o||n.charAt(o)===`-`)&&n.substr(0,o)===a&&e(t)}},element(e,t,n){let{adapter:r}=n,{name:i,value:a}=t;if(/\s/.test(a))return Z.default.falseFunc;let o=RegExp(`(?:^|\\s)${c6(a)}(?:$|\\s)`,u6(t,n)?`i`:``);return function(t){let n=r.getAttributeValue(t,i);return n!=null&&n.length>=a.length&&o.test(n)&&e(t)}},exists(e,{name:t},{adapter:n}){return r=>n.hasAttrib(r,t)&&e(r)},start(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t,o=a.length;return o===0?Z.default.falseFunc:u6(t,n)?(a=a.toLowerCase(),t=>{let n=r.getAttributeValue(t,i);return n!=null&&n.length>=o&&n.substr(0,o).toLowerCase()===a&&e(t)}):t=>!!r.getAttributeValue(t,i)?.startsWith(a)&&e(t)},end(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t,o=-a.length;return o===0?Z.default.falseFunc:u6(t,n)?(a=a.toLowerCase(),t=>r.getAttributeValue(t,i)?.substr(o).toLowerCase()===a&&e(t)):t=>!!r.getAttributeValue(t,i)?.endsWith(a)&&e(t)},any(e,t,n){let{adapter:r}=n,{name:i,value:a}=t;if(a===``)return Z.default.falseFunc;if(u6(t,n)){let t=new RegExp(c6(a),`i`);return function(n){let o=r.getAttributeValue(n,i);return o!=null&&o.length>=a.length&&t.test(o)&&e(n)}}return t=>!!r.getAttributeValue(t,i)?.includes(a)&&e(t)},not(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t;return a===``?t=>!!r.getAttributeValue(t,i)&&e(t):u6(t,n)?(a=a.toLowerCase(),t=>{let n=r.getAttributeValue(t,i);return(n==null||n.length!==a.length||n.toLowerCase()!==a)&&e(t)}):t=>r.getAttributeValue(t,i)!==a&&e(t)}},f6=new Set([9,10,12,13,32]);function p6(e){if(e=e.trim().toLowerCase(),e===`even`)return[2,0];if(e===`odd`)return[2,1];let t=0,n=0,r=a(),i=o();if(t<e.length&&e.charAt(t)===`n`&&(t++,n=r*(i??1),s(),t<e.length?(r=a(),s(),i=o()):r=i=0),i===null||t<e.length)throw Error(`n-th rule couldn't be parsed ('${e}')`);return[n,r*i];function a(){return e.charAt(t)===`-`?(t++,-1):(e.charAt(t)===`+`&&t++,1)}function o(){let n=t,r=0;for(;t<e.length&&e.charCodeAt(t)>=48&&e.charCodeAt(t)<=57;)r=r*10+(e.charCodeAt(t)-48),t++;return t===n?null:r}function s(){for(;t<e.length&&f6.has(e.charCodeAt(t));)t++}}function m6(e){let t=e[0],n=e[1]-1;if(n<0&&t<=0)return Z.default.falseFunc;if(t===-1)return e=>e<=n;if(t===0)return e=>e===n;if(t===1)return n<0?Z.default.trueFunc:e=>e>=n;let r=Math.abs(t),i=(n%r+r)%r;return t>1?e=>e>=n&&e%r===i:e=>e<=n&&e%r===i}function h6(e){return m6(p6(e))}function g6(e,t){return n=>{let r=t.getParent(n);return r!=null&&t.isTag(r)&&e(n)}}const _6={contains(e,t,{adapter:n}){return function(r){return e(r)&&n.getText(r).includes(t)}},icontains(e,t,{adapter:n}){let r=t.toLowerCase();return function(t){return e(t)&&n.getText(t).toLowerCase().includes(r)}},"nth-child"(e,t,{adapter:n,equals:r}){let i=h6(t);return i===Z.default.falseFunc?Z.default.falseFunc:i===Z.default.trueFunc?g6(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=0;e<a.length&&!r(t,a[e]);e++)n.isTag(a[e])&&o++;return i(o)&&e(t)}},"nth-last-child"(e,t,{adapter:n,equals:r}){let i=h6(t);return i===Z.default.falseFunc?Z.default.falseFunc:i===Z.default.trueFunc?g6(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=a.length-1;e>=0&&!r(t,a[e]);e--)n.isTag(a[e])&&o++;return i(o)&&e(t)}},"nth-of-type"(e,t,{adapter:n,equals:r}){let i=h6(t);return i===Z.default.falseFunc?Z.default.falseFunc:i===Z.default.trueFunc?g6(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=0;e<a.length;e++){let i=a[e];if(r(t,i))break;n.isTag(i)&&n.getName(i)===n.getName(t)&&o++}return i(o)&&e(t)}},"nth-last-of-type"(e,t,{adapter:n,equals:r}){let i=h6(t);return i===Z.default.falseFunc?Z.default.falseFunc:i===Z.default.trueFunc?g6(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=a.length-1;e>=0;e--){let i=a[e];if(r(t,i))break;n.isTag(i)&&n.getName(i)===n.getName(t)&&o++}return i(o)&&e(t)}},root(e,t,{adapter:n}){return t=>{let r=n.getParent(t);return(r==null||!n.isTag(r))&&e(t)}},scope(e,t,n,r){let{equals:i}=n;return!r||r.length===0?_6.root(e,t,n):r.length===1?t=>i(r[0],t)&&e(t):t=>r.includes(t)&&e(t)},hover:v6(`isHovered`),visited:v6(`isVisited`),active:v6(`isActive`)};function v6(e){return function(t,n,{adapter:r}){let i=r[e];return typeof i==`function`?function(e){return i(e)&&t(e)}:Z.default.falseFunc}}const y6={empty(e,{adapter:t}){return!t.getChildren(e).some(e=>t.isTag(e)||t.getText(e)!==``)},"first-child"(e,{adapter:t,equals:n}){if(t.prevElementSibling)return t.prevElementSibling(e)==null;let r=t.getSiblings(e).find(e=>t.isTag(e));return r!=null&&n(e,r)},"last-child"(e,{adapter:t,equals:n}){let r=t.getSiblings(e);for(let i=r.length-1;i>=0;i--){if(n(e,r[i]))return!0;if(t.isTag(r[i]))break}return!1},"first-of-type"(e,{adapter:t,equals:n}){let r=t.getSiblings(e),i=t.getName(e);for(let a=0;a<r.length;a++){let o=r[a];if(n(e,o))return!0;if(t.isTag(o)&&t.getName(o)===i)break}return!1},"last-of-type"(e,{adapter:t,equals:n}){let r=t.getSiblings(e),i=t.getName(e);for(let a=r.length-1;a>=0;a--){let o=r[a];if(n(e,o))return!0;if(t.isTag(o)&&t.getName(o)===i)break}return!1},"only-of-type"(e,{adapter:t,equals:n}){let r=t.getName(e);return t.getSiblings(e).every(i=>n(e,i)||!t.isTag(i)||t.getName(i)!==r)},"only-child"(e,{adapter:t,equals:n}){return t.getSiblings(e).every(r=>n(e,r)||!t.isTag(r))}};function b6(e,t,n,r){if(n===null){if(e.length>r)throw Error(`Pseudo-class :${t} requires an argument`)}else if(e.length===r)throw Error(`Pseudo-class :${t} doesn't have any arguments`)}const x6={"any-link":`:is(a, area, link)[href]`,link:`:any-link:not(:visited)`,disabled:`:is(
1781
+ :is(button, input, select, textarea, optgroup, option)[disabled],
1782
+ optgroup[disabled] > option,
1783
+ fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
1784
+ )`,enabled:`:not(:disabled)`,checked:`:is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)`,required:`:is(input, select, textarea)[required]`,optional:`:is(input, select, textarea):not([required])`,selected:`option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)`,checkbox:`[type=checkbox]`,file:`[type=file]`,password:`[type=password]`,radio:`[type=radio]`,reset:`[type=reset]`,image:`[type=image]`,submit:`[type=submit]`,parent:`:not(:empty)`,header:`:is(h1, h2, h3, h4, h5, h6)`,button:`:is(button, input[type=button])`,input:`:is(input, textarea, select, button)`,text:`input:is(:not([type!='']), [type=text])`},S6={};function C6(e,t){return e===Z.default.falseFunc?Z.default.falseFunc:n=>t.isTag(n)&&e(n)}function w6(e,t){let n=t.getSiblings(e);if(n.length<=1)return[];let r=n.indexOf(e);return r<0||r===n.length-1?[]:n.slice(r+1).filter(t.isTag)}function T6(e){return{xmlMode:!!e.xmlMode,lowerCaseAttributeNames:!!e.lowerCaseAttributeNames,lowerCaseTags:!!e.lowerCaseTags,quirksMode:!!e.quirksMode,cacheResults:!!e.cacheResults,pseudos:e.pseudos,adapter:e.adapter,equals:e.equals}}const E6=(e,t,n,r,i)=>{let a=i(t,T6(n),r);return a===Z.default.trueFunc?e:a===Z.default.falseFunc?Z.default.falseFunc:t=>a(t)&&e(t)},D6={is:E6,matches:E6,where:E6,not(e,t,n,r,i){let a=i(t,T6(n),r);return a===Z.default.falseFunc?e:a===Z.default.trueFunc?Z.default.falseFunc:t=>!a(t)&&e(t)},has(e,t,n,r,i){let{adapter:a}=n,o=T6(n);o.relativeSelector=!0;let s=t.some(e=>e.some(r6))?[S6]:void 0,c=i(t,o,s);if(c===Z.default.falseFunc)return Z.default.falseFunc;let l=C6(c,a);if(s&&c!==Z.default.trueFunc){let{shouldTestNextSiblings:t=!1}=c;return n=>{if(!e(n))return!1;s[0]=n;let r=a.getChildren(n),i=t?[...r,...w6(n,a)]:r;return a.existsOne(l,i)}}return t=>e(t)&&a.existsOne(l,a.getChildren(t))}};function O6(e,t,n,r,i){let{name:a,data:o}=t;if(Array.isArray(o)){if(!(a in D6))throw Error(`Unknown pseudo-class :${a}(${o})`);return D6[a](e,o,n,r,i)}let s=n.pseudos?.[a],c=typeof s==`string`?s:x6[a];if(typeof c==`string`){if(o!=null)throw Error(`Pseudo ${a} doesn't have any arguments`);let t=e6(c);return D6.is(e,t,n,r,i)}if(typeof s==`function`)return b6(s,a,o,1),t=>s(t,o)&&e(t);if(a in _6)return _6[a](e,o,n,r);if(a in y6){let t=y6[a];return b6(t,a,o,2),r=>t(r,n,o)&&e(r)}throw Error(`Unknown pseudo-class :${a}`)}function k6(e,t){let n=t.getParent(e);return n&&t.isTag(n)?n:null}function A6(e,t,n,r,i){let{adapter:a,equals:o}=n;switch(t.type){case X.PseudoElement:throw Error(`Pseudo-elements are not supported by css-select`);case X.ColumnCombinator:throw Error(`Column combinators are not yet supported by css-select`);case X.Attribute:if(t.namespace!=null)throw Error(`Namespaced attributes are not yet supported by css-select`);return(!n.xmlMode||n.lowerCaseAttributeNames)&&(t.name=t.name.toLowerCase()),d6[t.action](e,t,n);case X.Pseudo:return O6(e,t,n,r,i);case X.Tag:{if(t.namespace!=null)throw Error(`Namespaced tag names are not yet supported by css-select`);let{name:r}=t;return(!n.xmlMode||n.lowerCaseTags)&&(r=r.toLowerCase()),function(t){return a.getName(t)===r&&e(t)}}case X.Descendant:{if(n.cacheResults===!1||typeof WeakSet>`u`)return function(t){let n=t;for(;n=k6(n,a);)if(e(n))return!0;return!1};let t=new WeakSet;return function(n){let r=n;for(;r=k6(r,a);)if(!t.has(r)){if(a.isTag(r)&&e(r))return!0;t.add(r)}return!1}}case`_flexibleDescendant`:return function(t){let n=t;do if(e(n))return!0;while(n=k6(n,a));return!1};case X.Parent:return function(t){return a.getChildren(t).some(t=>a.isTag(t)&&e(t))};case X.Child:return function(t){let n=a.getParent(t);return n!=null&&a.isTag(n)&&e(n)};case X.Sibling:return function(t){let n=a.getSiblings(t);for(let r=0;r<n.length;r++){let i=n[r];if(o(t,i))break;if(a.isTag(i)&&e(i))return!0}return!1};case X.Adjacent:return a.prevElementSibling?function(t){let n=a.prevElementSibling(t);return n!=null&&e(n)}:function(t){let n=a.getSiblings(t),r;for(let e=0;e<n.length;e++){let i=n[e];if(o(t,i))break;a.isTag(i)&&(r=i)}return!!r&&e(r)};case X.Universal:if(t.namespace!=null&&t.namespace!==`*`)throw Error(`Namespaced universal selectors are not yet supported by css-select`);return e}}function j6(e,t,n){return C6(M6(e,t,n),t.adapter)}function M6(e,t,n){return R6(typeof e==`string`?e6(e):e,t,n)}function N6(e){return e.type===X.Pseudo&&(e.name===`scope`||Array.isArray(e.data)&&e.data.some(e=>e.some(N6)))}const P6={type:X.Descendant},F6={type:`_flexibleDescendant`},I6={type:X.Pseudo,name:`scope`,data:null};function L6(e,{adapter:t},n){let r=!!n?.every(e=>{let n=t.isTag(e)&&t.getParent(e);return e===S6||n&&t.isTag(n)});for(let t of e){if(!(t.length>0&&r6(t[0])&&t[0].type!==X.Descendant))if(r&&!t.some(N6))t.unshift(P6);else continue;t.unshift(I6)}}function R6(e,t,n){e.forEach(a6),n=t.context??n;let r=Array.isArray(n),i=n&&(Array.isArray(n)?n:[n]);if(t.relativeSelector!==!1)L6(e,t,i);else if(e.some(e=>e.length>0&&r6(e[0])))throw Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let a=!1,o=e.map(e=>{if(e.length>=2){let[t,n]=e;t.type!==X.Pseudo||t.name!==`scope`||(r&&n.type===X.Descendant?e[1]=F6:(n.type===X.Adjacent||n.type===X.Sibling)&&(a=!0))}return z6(e,t,i)}).reduce(B6,Z.default.falseFunc);return o.shouldTestNextSiblings=a,o}function z6(e,t,n){return e.reduce((e,r)=>e===Z.default.falseFunc?Z.default.falseFunc:A6(e,r,t,n,R6),t.rootFunc??Z.default.trueFunc)}function B6(e,t){return t===Z.default.falseFunc||e===Z.default.trueFunc?e:e===Z.default.falseFunc||t===Z.default.trueFunc?t:function(n){return e(n)||t(n)}}const V6=(e,t)=>e===t,H6={adapter:l4,equals:V6};function U6(e){let t=e??H6;return t.adapter??=l4,t.equals??=t.adapter?.equals??V6,t}function W6(e){return function(t,n,r){return e(t,U6(n),r)}}const G6=W6(j6);function K6(e,t,n){let r=U6(n);return(typeof t==`function`?t:j6(t,r))(e)}const{isArray:q6}=Array,J6=({nodeType:e})=>e===1,Y6=(e,t)=>t.some(t=>J6(t)&&(e(t)||Y6(e,Z6(t)))),X6=(e,t)=>t===`class`?e.classList.value:e.getAttribute(t),Z6=({childNodes:e})=>e,Q6=e=>{let{localName:t}=e;return D4(e)?t.toLowerCase():t},$6=({parentNode:e})=>e,e8=e=>{let{parentNode:t}=e;return t?Z6(t):e},t8=e=>q6(e)?e.map(t8).join(``):J6(e)?t8(Z6(e)):e.nodeType===3?e.data:``,n8=(e,t)=>e.hasAttribute(t),r8=e=>{let{length:t}=e;for(;t--;){let n=e[t];if(t&&-1<e.lastIndexOf(n,t-1)){e.splice(t,1);continue}for(let{parentNode:r}=n;r;r=r.parentNode)if(e.includes(r)){e.splice(t,1);break}}return e},i8=(e,t)=>{let n=[];for(let r of t)J6(r)&&(e(r)&&n.push(r),n.push(...i8(e,Z6(r))));return n},a8=(e,t)=>{for(let n of t)if(e(n)||(n=a8(e,Z6(n))))return n;return null},o8={isTag:J6,existsOne:Y6,getAttributeValue:X6,getChildren:Z6,getName:Q6,getParent:$6,getSiblings:e8,getText:t8,hasAttrib:n8,removeSubsets:r8,findAll:i8,findOne:a8},s8=(e,t)=>G6(t,{context:t.includes(`:scope`)?e:void 0,xmlMode:!D4(e),adapter:o8}),c8=(e,t)=>K6(e,t,{strict:!0,context:t.includes(`:scope`)?e:void 0,xmlMode:!D4(e),adapter:o8});var l8=class e extends z3{constructor(e,t=``){super(e,`#text`,3,t)}get wholeText(){let e=[],{previousSibling:t,nextSibling:n}=this;for(;t&&t.nodeType===3;)e.unshift(t[P1]),t=t.previousSibling;for(e.push(this[P1]);n&&n.nodeType===3;)e.push(n[P1]),n=n.nextSibling;return e.join(``)}cloneNode(){let{ownerDocument:t,[P1]:n}=this;return new e(t,n)}toString(){return T3(this[P1])}};const u8=e=>e instanceof b3,d8=(e,t,n)=>{let{ownerDocument:r}=e;for(let i of n)e.insertBefore(u8(i)?i:new l8(r,i),t)};var f8=class extends b3{constructor(e,t,n){super(e,t,n),this[k1]=null,this[K]=this[G]={[K]:null,[O1]:this,[j1]:this,nodeType:-1,ownerDocument:this.ownerDocument,parentNode:null}}get childNodes(){let e=new v3,{firstChild:t}=this;for(;t;)e.push(t),t=j3(t);return e}get children(){let e=new v3,{firstElementChild:t}=this;for(;t;)e.push(t),t=M3(t);return e}get firstChild(){let{[K]:e,[G]:t}=this;for(;e.nodeType===2;)e=e[K];return e===t?null:e}get firstElementChild(){let{firstChild:e}=this;for(;e;){if(e.nodeType===1)return e;e=j3(e)}return null}get lastChild(){let e=this[G][O1];switch(e.nodeType){case-1:return e[j1];case 2:return null}return e===this?null:e}get lastElementChild(){let{lastChild:e}=this;for(;e;){if(e.nodeType===1)return e;e=A3(e)}return null}get childElementCount(){return this.children.length}prepend(...e){d8(this,this.firstChild,e)}append(...e){d8(this,this[G],e)}replaceChildren(...e){let{[K]:t,[G]:n}=this;for(;t!==n&&t.nodeType===2;)t=t[K];for(;t!==n;){let e=E4(t)[K];t.remove(),t=e}e.length&&d8(this,n,e)}getElementsByClassName(e){let t=new v3,{[K]:n,[G]:r}=this;for(;n!==r;)n.nodeType===1&&n.hasAttribute(`class`)&&n.classList.has(e)&&t.push(n),n=n[K];return t}getElementsByTagName(e){let t=new v3,{[K]:n,[G]:r}=this;for(;n!==r;)n.nodeType===1&&(n.localName===e||M4(n)===e)&&t.push(n),n=n[K];return t}querySelector(e){let t=s8(this,e),{[K]:n,[G]:r}=this;for(;n!==r;){if(n.nodeType===1&&t(n))return n;n=n.nodeType===1&&n.localName===`template`?n[G]:n[K]}return null}querySelectorAll(e){let t=s8(this,e),n=new v3,{[K]:r,[G]:i}=this;for(;r!==i;)r.nodeType===1&&t(r)&&n.push(r),r=r.nodeType===1&&r.localName===`template`?r[G]:r[K];return n}appendChild(e){return this.insertBefore(e,this[G])}contains(e){let t=e;for(;t&&t!==this;)t=t.parentNode;return t===this}insertBefore(e,t=null){if(e===t)return e;if(e===this)throw Error(`unable to append a node to itself`);let n=t||this[G];switch(e.nodeType){case 1:e.remove(),e.parentNode=this,k4(n[O1],e,n),s3(e,null),H4(e);break;case 11:{let{[k1]:t,firstChild:r,lastChild:i}=e;if(r){A4(n[O1],r,i,n),O4(e,e[G]),t&&t.replaceChildren();do r.parentNode=this,s3(r,null),r.nodeType===1&&H4(r);while(r!==i&&(r=j3(r)))}break}case 3:case 8:case 4:e.remove();default:e.parentNode=this,j4(n[O1],e,n),s3(e,null);break}return e}normalize(){let{[K]:e,[G]:t}=this;for(;e!==t;){let{[K]:t,[O1]:n,nodeType:r}=e;r===3&&(e[P1]?n&&n.nodeType===3&&(n.textContent+=e.textContent,e.remove()):e.remove()),e=t}}removeChild(e){if(e.parentNode!==this)throw Error(`node is not a child`);return e.remove(),e}replaceChild(e,t){let n=E4(t)[K];return t.remove(),this.insertBefore(e,n),t}},p8=class extends f8{getElementById(e){let{[K]:t,[G]:n}=this;for(;t!==n;){if(t.nodeType===1&&t.id===e)return t;t=t[K]}return null}cloneNode(e){let{ownerDocument:t,constructor:n}=this,r=new n(t);if(e){let{[G]:t}=r;for(let n of this.childNodes)r.insertBefore(n.cloneNode(e),t)}return r}toString(){let{childNodes:e,localName:t}=this;return`<${t}>${e.join(``)}</${t}>`}toJSON(){let e=[];return t3(this,e),e}},m8=class extends p8{constructor(e){super(e,`#document-fragment`,11)}},h8=class e extends b3{constructor(e,t,n=``,r=``){super(e,`#document-type`,10),this.name=t,this.publicId=n,this.systemId=r}cloneNode(){let{ownerDocument:t,name:n,publicId:r,systemId:i}=this;return new e(t,n,r,i)}toString(){let{name:e,publicId:t,systemId:n}=this,r=0<t.length,i=[e];return r&&i.push(`PUBLIC`,`"${t}"`),n.length&&(r||i.push(`SYSTEM`),i.push(`"${n}"`)),`<!DOCTYPE ${i.join(` `)}>`}toJSON(){let e=[];return n3(this,e),e}};const g8=e=>e.childNodes.join(``),_8=(e,t)=>{let{ownerDocument:n}=e,{constructor:r}=n,i=new r;i[_1]=n[_1];let{childNodes:a}=Y4(i,D4(e),t);e.replaceChildren(...a.map(v8,n))};function v8(e){switch(e.ownerDocument=this,e.nodeType){case 1:case 11:e.childNodes.forEach(v8,this);break}return e}var y8=e=>e.replace(/(([A-Z0-9])([A-Z0-9][a-z]))|(([a-z0-9]+)([A-Z]))/g,`$2$5-$3$6`).toLowerCase();const b8=new WeakMap,x8=e=>`data-${y8(e)}`,S8=e=>e.slice(5).replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),C8={get(e,t){if(t in e)return b8.get(e).getAttribute(x8(t))},set(e,t,n){return e[t]=n,b8.get(e).setAttribute(x8(t),n),!0},deleteProperty(e,t){return t in e&&b8.get(e).removeAttribute(x8(t)),delete e[t]}};var w8=class{constructor(e){for(let{name:t,value:n}of e.attributes)/^data-/.test(t)&&(this[S8(t)]=n);return b8.set(this,e),new Proxy(this,C8)}};w4(w8.prototype,null);const{add:T8}=Set.prototype,E8=(e,t)=>{for(let n of t)n&&T8.call(e,n)},D8=({[D1]:e,value:t})=>{let n=e.getAttributeNode(`class`);n?n.value=t:u3(e,new D3(e.ownerDocument,`class`,t))};var O8=class extends Set{constructor(e){super(),this[D1]=e;let t=e.getAttributeNode(`class`);t&&E8(this,t.value.split(/\s+/))}get length(){return this.size}get value(){return[...this].join(` `)}add(...e){E8(this,e),D8(this)}contains(e){return this.has(e)}remove(...e){for(let t of e)this.delete(t);D8(this)}toggle(e,t){if(this.has(e)){if(t)return!0;this.delete(e),D8(this)}else if(t||arguments.length===1)return super.add(e),D8(this),!0;return!1}replace(e,t){return this.has(e)?(this.delete(e),super.add(t),D8(this),!0):!1}supports(){return!0}};const k8=new WeakMap,A8=e=>[...e.keys()].filter(e=>e!==k1),j8=e=>{let t=k8.get(e).getAttributeNode(`style`);if((!t||t[h1]||e.get(k1)!==t)&&(e.clear(),t)){e.set(k1,t);for(let n of t[P1].split(/\s*;\s*/)){let[t,...r]=n.split(`:`);if(r.length>0){t=t.trim();let n=r.join(`:`).trim();t&&n&&e.set(t,n)}}}return t},M8={get(e,t){return t in P8?e[t]:(j8(e),t===`length`?A8(e).length:/^\d+$/.test(t)?A8(e)[t]:e.get(y8(t)))},set(e,t,n){if(t===`cssText`)e[t]=n;else{let r=j8(e);if(n==null?e.delete(y8(t)):e.set(y8(t),n),!r){let t=k8.get(e);r=t.ownerDocument.createAttribute(`style`),t.setAttributeNode(r),e.set(k1,r)}r[h1]=!1,r[P1]=e.toString()}return!0}};var N8=class extends Map{constructor(e){return super(),k8.set(this,e),new Proxy(this,M8)}get cssText(){return this.toString()}set cssText(e){k8.get(this).setAttribute(`style`,e)}getPropertyValue(e){let t=this[k1];return M8.get(t,e)}setProperty(e,t){let n=this[k1];M8.set(n,e,t)}removeProperty(e){let t=this[k1];M8.set(t,e,null)}[Symbol.iterator](){let e=this[k1];j8(e);let t=A8(e),{length:n}=t,r=0;return{next(){let e=r===n;return{done:e,value:e?null:t[r++]}}}}get[k1](){return this}toString(){let e=this[k1];j8(e);let t=[];return e.forEach(F8,t),t.join(`;`)}};const{prototype:P8}=N8;function F8(e,t){t!==k1&&this.push(`${t}:${e}`)}function I8(e){return e.currentTarget}var L8=class{static get BUBBLING_PHASE(){return 3}static get AT_TARGET(){return 2}static get CAPTURING_PHASE(){return 1}static get NONE(){return 0}constructor(e,t={}){this.type=e,this.bubbles=!!t.bubbles,this.cancelBubble=!1,this._stopImmediatePropagationFlag=!1,this.cancelable=!!t.cancelable,this.eventPhase=this.NONE,this.timeStamp=Date.now(),this.defaultPrevented=!1,this.originalTarget=null,this.returnValue=null,this.srcElement=null,this.target=null,this._path=[]}get BUBBLING_PHASE(){return 3}get AT_TARGET(){return 2}get CAPTURING_PHASE(){return 1}get NONE(){return 0}preventDefault(){this.defaultPrevented=!0}composedPath(){return this._path.map(I8)}stopPropagation(){this.cancelBubble=!0}stopImmediatePropagation(){this.stopPropagation(),this._stopImmediatePropagationFlag=!0}},R8=class extends Array{constructor(e){super(),this.ownerElement=e}getNamedItem(e){return this.ownerElement.getAttributeNode(e)}setNamedItem(e){this.ownerElement.setAttributeNode(e),this.unshift(e)}removeNamedItem(e){let t=this.getNamedItem(e);this.ownerElement.removeAttribute(e),this.splice(this.indexOf(t),1)}item(e){return e<this.length?this[e]:null}getNamedItemNS(e,t){return this.getNamedItem(t)}setNamedItemNS(e,t){return this.setNamedItem(t)}removeNamedItemNS(e,t){return this.removeNamedItem(t)}},z8=class extends p8{constructor(e){super(e.ownerDocument,`#shadow-root`,11),this.host=e}get innerHTML(){return g8(this)}set innerHTML(e){_8(this,e)}};const B8={get(e,t){return t in e?e[t]:e.find(({name:e})=>e===t)}},V8=(e,t,n)=>{if(`ownerSVGElement`in t){let r=e.createElementNS(v4,n);return r.ownerSVGElement=t.ownerSVGElement,r}return e.createElement(n)},H8=({localName:e,ownerDocument:t})=>t[T1].voidElements.test(e);var U8=class extends f8{constructor(e,t){super(e,t,1),this[g1]=null,this[y1]=null,this[M1]=null}get isConnected(){return O3(this)}get parentElement(){return k3(this)}get previousSibling(){return A3(this)}get nextSibling(){return j3(this)}get namespaceURI(){return`http://www.w3.org/1999/xhtml`}get previousElementSibling(){return N3(this)}get nextElementSibling(){return M3(this)}before(...e){F3(this,e)}after(...e){I3(this,e)}replaceWith(...e){L3(this,e)}remove(){R3(this[O1],this,this[G][K])}get id(){return Y.get(this,`id`)}set id(e){Y.set(this,`id`,e)}get className(){return this.classList.value}set className(e){let{classList:t}=this;t.clear(),t.add(...T4(e).split(/\s+/))}get nodeName(){return M4(this)}get tagName(){return M4(this)}get classList(){return this[g1]||(this[g1]=new O8(this))}get dataset(){return this[y1]||(this[y1]=new w8(this))}getBoundingClientRect(){return{x:0,y:0,bottom:0,height:0,left:0,right:0,top:0,width:0}}get nonce(){return Y.get(this,`nonce`)}set nonce(e){Y.set(this,`nonce`,e)}get style(){return this[M1]||(this[M1]=new N8(this))}get tabIndex(){return p3.get(this,`tabindex`)||-1}set tabIndex(e){p3.set(this,`tabindex`,e)}get slot(){return Y.get(this,`slot`)}set slot(e){Y.set(this,`slot`,e)}get innerText(){let e=[],{[K]:t,[G]:n}=this;for(;t!==n;)t.nodeType===3?e.push(t.textContent.replace(/\s+/g,` `)):e.length&&t[K]!=n&&_4.has(t.tagName)&&e.push(`
1785
+ `),t=t[K];return e.join(``)}get textContent(){let e=[],{[K]:t,[G]:n}=this;for(;t!==n;){let n=t.nodeType;(n===3||n===4)&&e.push(t.textContent),t=t[K]}return e.join(``)}set textContent(e){this.replaceChildren(),e!=null&&e!==``&&this.appendChild(new l8(this.ownerDocument,e))}get innerHTML(){return g8(this)}set innerHTML(e){_8(this,e)}get outerHTML(){return this.toString()}set outerHTML(e){let t=this.ownerDocument.createElement(``);t.innerHTML=e,this.replaceWith(...t.childNodes)}get attributes(){let e=new R8(this),t=this[K];for(;t.nodeType===2;)e.push(t),t=t[K];return new Proxy(e,B8)}focus(){this.dispatchEvent(new L8(`focus`))}getAttribute(e){if(e===`class`)return this.className;let t=this.getAttributeNode(e);return t&&(D4(this)?t.value:T3(t.value))}getAttributeNode(e){let t=this[K];for(;t.nodeType===2;){if(t.name===e)return t;t=t[K]}return null}getAttributeNames(){let e=new v3,t=this[K];for(;t.nodeType===2;)e.push(t.name),t=t[K];return e}hasAttribute(e){return!!this.getAttributeNode(e)}hasAttributes(){return this[K].nodeType===2}removeAttribute(e){e===`class`&&this[g1]&&this[g1].clear();let t=this[K];for(;t.nodeType===2;){if(t.name===e){d3(this,t);return}t=t[K]}}removeAttributeNode(e){let t=this[K];for(;t.nodeType===2;){if(t===e){d3(this,t);return}t=t[K]}}setAttribute(e,t){if(e===`class`)this.className=t;else{let n=this.getAttributeNode(e);n?n.value=t:u3(this,new D3(this.ownerDocument,e,t))}}setAttributeNode(e){let{name:t}=e,n=this.getAttributeNode(t);if(n!==e){n&&this.removeAttributeNode(n);let{ownerElement:t}=e;t&&t.removeAttributeNode(e),u3(this,e)}return n}toggleAttribute(e,t){return this.hasAttribute(e)?t?!0:(this.removeAttribute(e),!1):t||arguments.length===1?(this.setAttribute(e,``),!0):!1}get shadowRoot(){if(F4.has(this)){let{mode:e,shadowRoot:t}=F4.get(this);if(e===`open`)return t}return null}attachShadow(e){if(F4.has(this))throw Error(`operation not supported`);let t=new z8(this);return F4.set(this,{mode:e.mode,shadowRoot:t}),t}matches(e){return c8(this,e)}closest(e){let t=this,n=s8(t,e);for(;t&&!n(t);)t=t.parentElement;return t}insertAdjacentElement(e,t){let{parentElement:n}=this;switch(e){case`beforebegin`:if(n){n.insertBefore(t,this);break}return null;case`afterbegin`:this.insertBefore(t,this.firstChild);break;case`beforeend`:this.insertBefore(t,null);break;case`afterend`:if(n){n.insertBefore(t,this.nextSibling);break}return null}return t}insertAdjacentHTML(e,t){this.insertAdjacentElement(e,P4(this.ownerDocument,t))}insertAdjacentText(e,t){let n=this.ownerDocument.createTextNode(t);this.insertAdjacentElement(e,n)}cloneNode(e=!1){let{ownerDocument:t,localName:n}=this,r=e=>{e.parentNode=a,O4(o,e),o=e},i=V8(t,this,n),a=i,o=i,{[K]:s,[G]:c}=this;for(;s!==c&&(e||s.nodeType===2);){switch(s.nodeType){case-1:O4(o,a[G]),o=a[G],a=a.parentNode;break;case 1:{let e=V8(t,s,s.localName);r(e),a=e;break}case 2:{let t=s.cloneNode(e);t.ownerElement=a,r(t);break}case 3:case 8:case 4:r(s.cloneNode(e));break}s=s[K]}return O4(o,i[G]),i}toString(){let e=[],{[G]:t}=this,n={[K]:this},r=!1;do switch(n=n[K],n.nodeType){case 2:{let t=` `+n;switch(t){case` id`:case` class`:case` style`:break;default:e.push(t)}break}case-1:{let t=n[j1];r?(`ownerSVGElement`in t?e.push(` />`):H8(t)?e.push(D4(t)?`>`:` />`):e.push(`></${t.localName}>`),r=!1):e.push(`</${t.localName}>`);break}case 1:r&&e.push(`>`),n.toString===this.toString?(e.push(`<${n.localName}`),r=!0):(e.push(n.toString()),n=n[G],r=!1);break;case 3:case 8:case 4:e.push((r?`>`:``)+n),r=!1;break}while(n!==t);return e.join(``)}toJSON(){let e=[];return r3(this,e),e}getAttributeNS(e,t){return this.getAttribute(t)}getElementsByTagNameNS(e,t){return this.getElementsByTagName(t)}hasAttributeNS(e,t){return this.hasAttribute(t)}removeAttributeNS(e,t){this.removeAttribute(t)}setAttributeNS(e,t,n){this.setAttribute(t,n)}setAttributeNodeNS(e){return this.setAttributeNode(e)}};const W8=new WeakMap,G8={get(e,t){return e[t]},set(e,t,n){return e[t]=n,!0}};var K8=class extends U8{constructor(e,t,n=null){super(e,t),this.ownerSVGElement=n}get className(){return W8.has(this)||W8.set(this,new Proxy({baseVal:``,animVal:``},G8)),W8.get(this)}set className(e){let{classList:t}=this;t.clear(),t.add(...T4(e).split(/\s+/))}get namespaceURI(){return`http://www.w3.org/2000/svg`}getAttribute(e){return e===`class`?[...this.classList].join(` `):super.getAttribute(e)}setAttribute(e,t){if(e===`class`)this.className=t;else if(e===`style`){let{className:e}=this;e.baseVal=e.animVal=t}super.setAttribute(e,t)}};const q8=()=>{throw TypeError(`Illegal constructor`)};function J8(){q8()}w4(J8,D3),J8.prototype=D3.prototype;function Y8(){q8()}w4(Y8,B3),Y8.prototype=B3.prototype;function X8(){q8()}w4(X8,z3),X8.prototype=z3.prototype;function Z8(){q8()}w4(Z8,V3),Z8.prototype=V3.prototype;function Q8(){q8()}w4(Q8,m8),Q8.prototype=m8.prototype;function $8(){q8()}w4($8,h8),$8.prototype=h8.prototype;function e5(){q8()}w4(e5,U8),e5.prototype=U8.prototype;function t5(){q8()}w4(t5,b3),t5.prototype=b3.prototype;function n5(){q8()}w4(n5,z8),n5.prototype=z8.prototype;function r5(){q8()}w4(r5,l8),r5.prototype=l8.prototype;function i5(){q8()}w4(i5,K8),i5.prototype=K8.prototype;const a5={Attr:J8,CDATASection:Y8,CharacterData:X8,Comment:Z8,DocumentFragment:Q8,DocumentType:$8,Element:e5,Node:t5,ShadowRoot:n5,Text:r5,SVGElement:i5},o5=new WeakMap,Q={get(e,t){return o5.has(e)&&o5.get(e)[t]||null},set(e,t,n){o5.has(e)||o5.set(e,{});let r=o5.get(e),i=t.slice(2);r[t]&&e.removeEventListener(i,r[t],!1),(r[t]=n)&&e.addEventListener(i,n,!1)}};var $=class extends U8{static get observedAttributes(){return[]}constructor(e=null,t=``){super(e,t);let n=!e,r;if(n){let{constructor:n}=this;if(!L4.has(n))throw Error(`unable to initialize this Custom Element`);({ownerDocument:e,localName:t,options:r}=L4.get(n))}if(e[N1]){let{element:t,values:n}=e[N1];e[N1]=null;for(let[e,r]of n)t[e]=r;return t}n&&(this.ownerDocument=this[G].ownerDocument=e,this.localName=t,R4.set(this,{connected:!1}),r.is&&this.setAttribute(`is`,r.is))}blur(){this.dispatchEvent(new L8(`blur`))}click(){let e=new L8(`click`,{bubbles:!0,cancelable:!0});e.button=0,this.dispatchEvent(e)}get accessKeyLabel(){let{accessKey:e}=this;return e&&`Alt+Shift+${e}`}get isContentEditable(){return this.hasAttribute(`contenteditable`)}get contentEditable(){return f3.get(this,`contenteditable`)}set contentEditable(e){f3.set(this,`contenteditable`,e)}get draggable(){return f3.get(this,`draggable`)}set draggable(e){f3.set(this,`draggable`,e)}get hidden(){return f3.get(this,`hidden`)}set hidden(e){f3.set(this,`hidden`,e)}get spellcheck(){return f3.get(this,`spellcheck`)}set spellcheck(e){f3.set(this,`spellcheck`,e)}get accessKey(){return Y.get(this,`accesskey`)}set accessKey(e){Y.set(this,`accesskey`,e)}get dir(){return Y.get(this,`dir`)}set dir(e){Y.set(this,`dir`,e)}get lang(){return Y.get(this,`lang`)}set lang(e){Y.set(this,`lang`,e)}get title(){return Y.get(this,`title`)}set title(e){Y.set(this,`title`,e)}get onabort(){return Q.get(this,`onabort`)}set onabort(e){Q.set(this,`onabort`,e)}get onblur(){return Q.get(this,`onblur`)}set onblur(e){Q.set(this,`onblur`,e)}get oncancel(){return Q.get(this,`oncancel`)}set oncancel(e){Q.set(this,`oncancel`,e)}get oncanplay(){return Q.get(this,`oncanplay`)}set oncanplay(e){Q.set(this,`oncanplay`,e)}get oncanplaythrough(){return Q.get(this,`oncanplaythrough`)}set oncanplaythrough(e){Q.set(this,`oncanplaythrough`,e)}get onchange(){return Q.get(this,`onchange`)}set onchange(e){Q.set(this,`onchange`,e)}get onclick(){return Q.get(this,`onclick`)}set onclick(e){Q.set(this,`onclick`,e)}get onclose(){return Q.get(this,`onclose`)}set onclose(e){Q.set(this,`onclose`,e)}get oncontextmenu(){return Q.get(this,`oncontextmenu`)}set oncontextmenu(e){Q.set(this,`oncontextmenu`,e)}get oncuechange(){return Q.get(this,`oncuechange`)}set oncuechange(e){Q.set(this,`oncuechange`,e)}get ondblclick(){return Q.get(this,`ondblclick`)}set ondblclick(e){Q.set(this,`ondblclick`,e)}get ondrag(){return Q.get(this,`ondrag`)}set ondrag(e){Q.set(this,`ondrag`,e)}get ondragend(){return Q.get(this,`ondragend`)}set ondragend(e){Q.set(this,`ondragend`,e)}get ondragenter(){return Q.get(this,`ondragenter`)}set ondragenter(e){Q.set(this,`ondragenter`,e)}get ondragleave(){return Q.get(this,`ondragleave`)}set ondragleave(e){Q.set(this,`ondragleave`,e)}get ondragover(){return Q.get(this,`ondragover`)}set ondragover(e){Q.set(this,`ondragover`,e)}get ondragstart(){return Q.get(this,`ondragstart`)}set ondragstart(e){Q.set(this,`ondragstart`,e)}get ondrop(){return Q.get(this,`ondrop`)}set ondrop(e){Q.set(this,`ondrop`,e)}get ondurationchange(){return Q.get(this,`ondurationchange`)}set ondurationchange(e){Q.set(this,`ondurationchange`,e)}get onemptied(){return Q.get(this,`onemptied`)}set onemptied(e){Q.set(this,`onemptied`,e)}get onended(){return Q.get(this,`onended`)}set onended(e){Q.set(this,`onended`,e)}get onerror(){return Q.get(this,`onerror`)}set onerror(e){Q.set(this,`onerror`,e)}get onfocus(){return Q.get(this,`onfocus`)}set onfocus(e){Q.set(this,`onfocus`,e)}get oninput(){return Q.get(this,`oninput`)}set oninput(e){Q.set(this,`oninput`,e)}get oninvalid(){return Q.get(this,`oninvalid`)}set oninvalid(e){Q.set(this,`oninvalid`,e)}get onkeydown(){return Q.get(this,`onkeydown`)}set onkeydown(e){Q.set(this,`onkeydown`,e)}get onkeypress(){return Q.get(this,`onkeypress`)}set onkeypress(e){Q.set(this,`onkeypress`,e)}get onkeyup(){return Q.get(this,`onkeyup`)}set onkeyup(e){Q.set(this,`onkeyup`,e)}get onload(){return Q.get(this,`onload`)}set onload(e){Q.set(this,`onload`,e)}get onloadeddata(){return Q.get(this,`onloadeddata`)}set onloadeddata(e){Q.set(this,`onloadeddata`,e)}get onloadedmetadata(){return Q.get(this,`onloadedmetadata`)}set onloadedmetadata(e){Q.set(this,`onloadedmetadata`,e)}get onloadstart(){return Q.get(this,`onloadstart`)}set onloadstart(e){Q.set(this,`onloadstart`,e)}get onmousedown(){return Q.get(this,`onmousedown`)}set onmousedown(e){Q.set(this,`onmousedown`,e)}get onmouseenter(){return Q.get(this,`onmouseenter`)}set onmouseenter(e){Q.set(this,`onmouseenter`,e)}get onmouseleave(){return Q.get(this,`onmouseleave`)}set onmouseleave(e){Q.set(this,`onmouseleave`,e)}get onmousemove(){return Q.get(this,`onmousemove`)}set onmousemove(e){Q.set(this,`onmousemove`,e)}get onmouseout(){return Q.get(this,`onmouseout`)}set onmouseout(e){Q.set(this,`onmouseout`,e)}get onmouseover(){return Q.get(this,`onmouseover`)}set onmouseover(e){Q.set(this,`onmouseover`,e)}get onmouseup(){return Q.get(this,`onmouseup`)}set onmouseup(e){Q.set(this,`onmouseup`,e)}get onmousewheel(){return Q.get(this,`onmousewheel`)}set onmousewheel(e){Q.set(this,`onmousewheel`,e)}get onpause(){return Q.get(this,`onpause`)}set onpause(e){Q.set(this,`onpause`,e)}get onplay(){return Q.get(this,`onplay`)}set onplay(e){Q.set(this,`onplay`,e)}get onplaying(){return Q.get(this,`onplaying`)}set onplaying(e){Q.set(this,`onplaying`,e)}get onprogress(){return Q.get(this,`onprogress`)}set onprogress(e){Q.set(this,`onprogress`,e)}get onratechange(){return Q.get(this,`onratechange`)}set onratechange(e){Q.set(this,`onratechange`,e)}get onreset(){return Q.get(this,`onreset`)}set onreset(e){Q.set(this,`onreset`,e)}get onresize(){return Q.get(this,`onresize`)}set onresize(e){Q.set(this,`onresize`,e)}get onscroll(){return Q.get(this,`onscroll`)}set onscroll(e){Q.set(this,`onscroll`,e)}get onseeked(){return Q.get(this,`onseeked`)}set onseeked(e){Q.set(this,`onseeked`,e)}get onseeking(){return Q.get(this,`onseeking`)}set onseeking(e){Q.set(this,`onseeking`,e)}get onselect(){return Q.get(this,`onselect`)}set onselect(e){Q.set(this,`onselect`,e)}get onshow(){return Q.get(this,`onshow`)}set onshow(e){Q.set(this,`onshow`,e)}get onstalled(){return Q.get(this,`onstalled`)}set onstalled(e){Q.set(this,`onstalled`,e)}get onsubmit(){return Q.get(this,`onsubmit`)}set onsubmit(e){Q.set(this,`onsubmit`,e)}get onsuspend(){return Q.get(this,`onsuspend`)}set onsuspend(e){Q.set(this,`onsuspend`,e)}get ontimeupdate(){return Q.get(this,`ontimeupdate`)}set ontimeupdate(e){Q.set(this,`ontimeupdate`,e)}get ontoggle(){return Q.get(this,`ontoggle`)}set ontoggle(e){Q.set(this,`ontoggle`,e)}get onvolumechange(){return Q.get(this,`onvolumechange`)}set onvolumechange(e){Q.set(this,`onvolumechange`,e)}get onwaiting(){return Q.get(this,`onwaiting`)}set onwaiting(e){Q.set(this,`onwaiting`,e)}get onauxclick(){return Q.get(this,`onauxclick`)}set onauxclick(e){Q.set(this,`onauxclick`,e)}get ongotpointercapture(){return Q.get(this,`ongotpointercapture`)}set ongotpointercapture(e){Q.set(this,`ongotpointercapture`,e)}get onlostpointercapture(){return Q.get(this,`onlostpointercapture`)}set onlostpointercapture(e){Q.set(this,`onlostpointercapture`,e)}get onpointercancel(){return Q.get(this,`onpointercancel`)}set onpointercancel(e){Q.set(this,`onpointercancel`,e)}get onpointerdown(){return Q.get(this,`onpointerdown`)}set onpointerdown(e){Q.set(this,`onpointerdown`,e)}get onpointerenter(){return Q.get(this,`onpointerenter`)}set onpointerenter(e){Q.set(this,`onpointerenter`,e)}get onpointerleave(){return Q.get(this,`onpointerleave`)}set onpointerleave(e){Q.set(this,`onpointerleave`,e)}get onpointermove(){return Q.get(this,`onpointermove`)}set onpointermove(e){Q.set(this,`onpointermove`,e)}get onpointerout(){return Q.get(this,`onpointerout`)}set onpointerout(e){Q.set(this,`onpointerout`,e)}get onpointerover(){return Q.get(this,`onpointerover`)}set onpointerover(e){Q.set(this,`onpointerover`,e)}get onpointerup(){return Q.get(this,`onpointerup`)}set onpointerup(e){Q.set(this,`onpointerup`,e)}};const s5=`template`;var c5=class extends ${constructor(e){super(e,s5);let t=this.ownerDocument.createDocumentFragment();(this[v1]=t)[k1]=this}get content(){if(this.hasChildNodes()&&!this[v1].hasChildNodes())for(let e of this.childNodes)this[v1].appendChild(e.cloneNode(!0));return this[v1]}};Z4(s5,c5);var l5=class extends ${constructor(e,t=`html`){super(e,t)}};const{toString:u5}=$.prototype;var d5=class extends ${get innerHTML(){return this.textContent}set innerHTML(e){this.textContent=e}toString(){return u5.call(this.cloneNode()).replace(`><`,()=>`>${this.textContent}<`)}};const f5=`script`;var p5=class extends d5{constructor(e,t=f5){super(e,t)}get type(){return Y.get(this,`type`)}set type(e){Y.set(this,`type`,e)}get src(){return Y.get(this,`src`)}set src(e){Y.set(this,`src`,e)}get defer(){return f3.get(this,`defer`)}set defer(e){f3.set(this,`defer`,e)}get crossOrigin(){return Y.get(this,`crossorigin`)}set crossOrigin(e){Y.set(this,`crossorigin`,e)}get nomodule(){return f3.get(this,`nomodule`)}set nomodule(e){f3.set(this,`nomodule`,e)}get referrerPolicy(){return Y.get(this,`referrerpolicy`)}set referrerPolicy(e){Y.set(this,`referrerpolicy`,e)}get nonce(){return Y.get(this,`nonce`)}set nonce(e){Y.set(this,`nonce`,e)}get async(){return f3.get(this,`async`)}set async(e){f3.set(this,`async`,e)}get text(){return this.textContent}set text(e){this.textContent=e}};Z4(f5,p5);var m5=class extends ${constructor(e,t=`frame`){super(e,t)}};const h5=`iframe`;var g5=class extends ${constructor(e,t=h5){super(e,t)}get src(){return Y.get(this,`src`)}set src(e){Y.set(this,`src`,e)}get srcdoc(){return Y.get(this,`srcdoc`)}set srcdoc(e){Y.set(this,`srcdoc`,e)}get name(){return Y.get(this,`name`)}set name(e){Y.set(this,`name`,e)}get allow(){return Y.get(this,`allow`)}set allow(e){Y.set(this,`allow`,e)}get allowFullscreen(){return f3.get(this,`allowfullscreen`)}set allowFullscreen(e){f3.set(this,`allowfullscreen`,e)}get referrerPolicy(){return Y.get(this,`referrerpolicy`)}set referrerPolicy(e){Y.set(this,`referrerpolicy`,e)}get loading(){return Y.get(this,`loading`)}set loading(e){Y.set(this,`loading`,e)}};Z4(h5,g5);var _5=class extends ${constructor(e,t=`object`){super(e,t)}},v5=class extends ${constructor(e,t=`head`){super(e,t)}},y5=class extends ${constructor(e,t=`body`){super(e,t)}},b5=s((e=>{var t={};t.StyleSheet=function(){this.parentStyleSheet=null},e.StyleSheet=t.StyleSheet})),x5=s((e=>{var t={};t.CSSRule=function(){this.parentRule=null,this.parentStyleSheet=null},t.CSSRule.UNKNOWN_RULE=0,t.CSSRule.STYLE_RULE=1,t.CSSRule.CHARSET_RULE=2,t.CSSRule.IMPORT_RULE=3,t.CSSRule.MEDIA_RULE=4,t.CSSRule.FONT_FACE_RULE=5,t.CSSRule.PAGE_RULE=6,t.CSSRule.KEYFRAMES_RULE=7,t.CSSRule.KEYFRAME_RULE=8,t.CSSRule.MARGIN_RULE=9,t.CSSRule.NAMESPACE_RULE=10,t.CSSRule.COUNTER_STYLE_RULE=11,t.CSSRule.SUPPORTS_RULE=12,t.CSSRule.DOCUMENT_RULE=13,t.CSSRule.FONT_FEATURE_VALUES_RULE=14,t.CSSRule.VIEWPORT_RULE=15,t.CSSRule.REGION_STYLE_RULE=16,t.CSSRule.prototype={constructor:t.CSSRule},e.CSSRule=t.CSSRule})),S5=s((e=>{var t={CSSStyleDeclaration:z5().CSSStyleDeclaration,CSSRule:x5().CSSRule};t.CSSStyleRule=function(){t.CSSRule.call(this),this.selectorText=``,this.style=new t.CSSStyleDeclaration,this.style.parentRule=this},t.CSSStyleRule.prototype=new t.CSSRule,t.CSSStyleRule.prototype.constructor=t.CSSStyleRule,t.CSSStyleRule.prototype.type=1,Object.defineProperty(t.CSSStyleRule.prototype,"cssText",{get:function(){return this.selectorText?this.selectorText+` {`+this.style.cssText+`}`:``},set:function(e){var n=t.CSSStyleRule.parse(e);this.style=n.style,this.selectorText=n.selectorText}}),t.CSSStyleRule.parse=function(e){for(var n=0,r=`selector`,i,a=n,o=``,s={selector:!0,value:!0},c=new t.CSSStyleRule,l,u=``,d;d=e.charAt(n);n++)switch(d){case` `:case` `:case`\r`:case`
1786
+ `:case`\f`:if(s[r])switch(e.charAt(n-1)){case` `:case` `:case`\r`:case`
1787
+ `:case`\f`:break;default:o+=` `;break}break;case`"`:if(a=n+1,i=e.indexOf(`"`,a)+1,!i)throw`" is missing`;o+=e.slice(n,i),n=i-1;break;case`'`:if(a=n+1,i=e.indexOf(`'`,a)+1,!i)throw`' is missing`;o+=e.slice(n,i),n=i-1;break;case`/`:if(e.charAt(n+1)===`*`){if(n+=2,i=e.indexOf(`*/`,n),i===-1)throw SyntaxError(`Missing */`);n=i+1}else o+=d;break;case`{`:r===`selector`&&(c.selectorText=o.trim(),o=``,r=`name`);break;case`:`:r===`name`?(l=o.trim(),o=``,r=`value`):o+=d;break;case`!`:r===`value`&&e.indexOf(`!important`,n)===n?(u=`important`,n+=9):o+=d;break;case`;`:r===`value`?(c.style.setProperty(l,o.trim(),u),u=``,o=``,r=`name`):o+=d;break;case`}`:if(r===`value`)c.style.setProperty(l,o.trim(),u),u=``,o=``;else if(r===`name`)break;else o+=d;r=`selector`;break;default:o+=d;break}return c},e.CSSStyleRule=t.CSSStyleRule})),C5=s((e=>{var t={StyleSheet:b5().StyleSheet,CSSStyleRule:S5().CSSStyleRule};t.CSSStyleSheet=function(){t.StyleSheet.call(this),this.cssRules=[]},t.CSSStyleSheet.prototype=new t.StyleSheet,t.CSSStyleSheet.prototype.constructor=t.CSSStyleSheet,t.CSSStyleSheet.prototype.insertRule=function(e,n){if(n<0||n>this.cssRules.length)throw RangeError(`INDEX_SIZE_ERR`);var r=t.parse(e).cssRules[0];return r.parentStyleSheet=this,this.cssRules.splice(n,0,r),n},t.CSSStyleSheet.prototype.deleteRule=function(e){if(e<0||e>=this.cssRules.length)throw RangeError(`INDEX_SIZE_ERR`);this.cssRules.splice(e,1)},t.CSSStyleSheet.prototype.toString=function(){for(var e=``,t=this.cssRules,n=0;n<t.length;n++)e+=t[n].cssText+`
1788
+ `;return e},e.CSSStyleSheet=t.CSSStyleSheet,t.parse=R5().parse})),w5=s((e=>{var t={};t.MediaList=function(){this.length=0},t.MediaList.prototype={constructor:t.MediaList,get mediaText(){return Array.prototype.join.call(this,`, `)},set mediaText(e){for(var t=e.split(`,`),n=this.length=t.length,r=0;r<n;r++)this[r]=t[r].trim()},appendMedium:function(e){Array.prototype.indexOf.call(this,e)===-1&&(this[this.length]=e,this.length++)},deleteMedium:function(e){var t=Array.prototype.indexOf.call(this,e);t!==-1&&Array.prototype.splice.call(this,t,1)}},e.MediaList=t.MediaList})),T5=s((e=>{var t={CSSRule:x5().CSSRule,CSSStyleSheet:C5().CSSStyleSheet,MediaList:w5().MediaList};t.CSSImportRule=function(){t.CSSRule.call(this),this.href=``,this.media=new t.MediaList,this.styleSheet=new t.CSSStyleSheet},t.CSSImportRule.prototype=new t.CSSRule,t.CSSImportRule.prototype.constructor=t.CSSImportRule,t.CSSImportRule.prototype.type=3,Object.defineProperty(t.CSSImportRule.prototype,"cssText",{get:function(){var e=this.media.mediaText;return`@import url(`+this.href+`)`+(e?` `+e:``)+`;`},set:function(e){for(var t=0,n=``,r=``,i,a;a=e.charAt(t);t++)switch(a){case` `:case` `:case`\r`:case`
1789
+ `:case`\f`:n===`after-import`?n=`url`:r+=a;break;case`@`:!n&&e.indexOf(`@import`,t)===t&&(n=`after-import`,t+=6,r=``);break;case`u`:if(n===`url`&&e.indexOf(`url(`,t)===t){if(i=e.indexOf(`)`,t+1),i===-1)throw t+`: ")" not found`;t+=4;var o=e.slice(t,i);o[0]===o[o.length-1]&&(o[0]===`"`||o[0]===`'`)&&(o=o.slice(1,-1)),this.href=o,t=i,n=`media`}break;case`"`:if(n===`url`){if(i=e.indexOf(`"`,t+1),!i)throw t+`: '"' not found`;this.href=e.slice(t+1,i),t=i,n=`media`}break;case`'`:if(n===`url`){if(i=e.indexOf(`'`,t+1),!i)throw t+`: "'" not found`;this.href=e.slice(t+1,i),t=i,n=`media`}break;case`;`:n===`media`&&r&&(this.media.mediaText=r.trim());break;default:n===`media`&&(r+=a);break}}}),e.CSSImportRule=t.CSSImportRule})),E5=s((e=>{var t={CSSRule:x5().CSSRule};t.CSSGroupingRule=function(){t.CSSRule.call(this),this.cssRules=[]},t.CSSGroupingRule.prototype=new t.CSSRule,t.CSSGroupingRule.prototype.constructor=t.CSSGroupingRule,t.CSSGroupingRule.prototype.insertRule=function(e,n){if(n<0||n>this.cssRules.length)throw RangeError(`INDEX_SIZE_ERR`);var r=t.parse(e).cssRules[0];return r.parentRule=this,this.cssRules.splice(n,0,r),n},t.CSSGroupingRule.prototype.deleteRule=function(e){if(e<0||e>=this.cssRules.length)throw RangeError(`INDEX_SIZE_ERR`);this.cssRules.splice(e,1)[0].parentRule=null},e.CSSGroupingRule=t.CSSGroupingRule})),D5=s((e=>{var t={CSSRule:x5().CSSRule,CSSGroupingRule:E5().CSSGroupingRule};t.CSSConditionRule=function(){t.CSSGroupingRule.call(this),this.cssRules=[]},t.CSSConditionRule.prototype=new t.CSSGroupingRule,t.CSSConditionRule.prototype.constructor=t.CSSConditionRule,t.CSSConditionRule.prototype.conditionText=``,t.CSSConditionRule.prototype.cssText=``,e.CSSConditionRule=t.CSSConditionRule})),O5=s((e=>{var t={CSSRule:x5().CSSRule,CSSGroupingRule:E5().CSSGroupingRule,CSSConditionRule:D5().CSSConditionRule,MediaList:w5().MediaList};t.CSSMediaRule=function(){t.CSSConditionRule.call(this),this.media=new t.MediaList},t.CSSMediaRule.prototype=new t.CSSConditionRule,t.CSSMediaRule.prototype.constructor=t.CSSMediaRule,t.CSSMediaRule.prototype.type=4,Object.defineProperties(t.CSSMediaRule.prototype,{conditionText:{get:function(){return this.media.mediaText},set:function(e){this.media.mediaText=e},configurable:!0,enumerable:!0},cssText:{get:function(){for(var e=[],t=0,n=this.cssRules.length;t<n;t++)e.push(this.cssRules[t].cssText);return`@media `+this.media.mediaText+` {`+e.join(``)+`}`},configurable:!0,enumerable:!0}}),e.CSSMediaRule=t.CSSMediaRule})),k5=s((e=>{var t={CSSRule:x5().CSSRule,CSSGroupingRule:E5().CSSGroupingRule,CSSConditionRule:D5().CSSConditionRule};t.CSSSupportsRule=function(){t.CSSConditionRule.call(this)},t.CSSSupportsRule.prototype=new t.CSSConditionRule,t.CSSSupportsRule.prototype.constructor=t.CSSSupportsRule,t.CSSSupportsRule.prototype.type=12,Object.defineProperty(t.CSSSupportsRule.prototype,"cssText",{get:function(){for(var e=[],t=0,n=this.cssRules.length;t<n;t++)e.push(this.cssRules[t].cssText);return`@supports `+this.conditionText+` {`+e.join(``)+`}`}}),e.CSSSupportsRule=t.CSSSupportsRule})),A5=s((e=>{var t={CSSStyleDeclaration:z5().CSSStyleDeclaration,CSSRule:x5().CSSRule};t.CSSFontFaceRule=function(){t.CSSRule.call(this),this.style=new t.CSSStyleDeclaration,this.style.parentRule=this},t.CSSFontFaceRule.prototype=new t.CSSRule,t.CSSFontFaceRule.prototype.constructor=t.CSSFontFaceRule,t.CSSFontFaceRule.prototype.type=5,Object.defineProperty(t.CSSFontFaceRule.prototype,"cssText",{get:function(){return`@font-face {`+this.style.cssText+`}`}}),e.CSSFontFaceRule=t.CSSFontFaceRule})),j5=s((e=>{var t={CSSRule:x5().CSSRule};t.CSSHostRule=function(){t.CSSRule.call(this),this.cssRules=[]},t.CSSHostRule.prototype=new t.CSSRule,t.CSSHostRule.prototype.constructor=t.CSSHostRule,t.CSSHostRule.prototype.type=1001,Object.defineProperty(t.CSSHostRule.prototype,"cssText",{get:function(){for(var e=[],t=0,n=this.cssRules.length;t<n;t++)e.push(this.cssRules[t].cssText);return`@host {`+e.join(``)+`}`}}),e.CSSHostRule=t.CSSHostRule})),M5=s((e=>{var t={CSSRule:x5().CSSRule,CSSStyleDeclaration:z5().CSSStyleDeclaration};t.CSSKeyframeRule=function(){t.CSSRule.call(this),this.keyText=``,this.style=new t.CSSStyleDeclaration,this.style.parentRule=this},t.CSSKeyframeRule.prototype=new t.CSSRule,t.CSSKeyframeRule.prototype.constructor=t.CSSKeyframeRule,t.CSSKeyframeRule.prototype.type=8,Object.defineProperty(t.CSSKeyframeRule.prototype,"cssText",{get:function(){return this.keyText+` {`+this.style.cssText+`} `}}),e.CSSKeyframeRule=t.CSSKeyframeRule})),N5=s((e=>{var t={CSSRule:x5().CSSRule};t.CSSKeyframesRule=function(){t.CSSRule.call(this),this.name=``,this.cssRules=[]},t.CSSKeyframesRule.prototype=new t.CSSRule,t.CSSKeyframesRule.prototype.constructor=t.CSSKeyframesRule,t.CSSKeyframesRule.prototype.type=7,Object.defineProperty(t.CSSKeyframesRule.prototype,"cssText",{get:function(){for(var e=[],t=0,n=this.cssRules.length;t<n;t++)e.push(` `+this.cssRules[t].cssText);return`@`+(this._vendorPrefix||``)+`keyframes `+this.name+` {
1790
+ `+e.join(`
1791
+ `)+`
1792
+ }`}}),e.CSSKeyframesRule=t.CSSKeyframesRule})),P5=s((e=>{var t={};t.CSSValue=function(){},t.CSSValue.prototype={constructor:t.CSSValue,set cssText(e){var t=this._getConstructorName();throw Error(`DOMException: property "cssText" of "`+t+`" is readonly and can not be replaced with "`+e+`"!`)},get cssText(){var e=this._getConstructorName();throw Error(`getter "cssText" of "`+e+`" is not implemented!`)},_getConstructorName:function(){return this.constructor.toString().match(/function\s([^\(]+)/)[1]}},e.CSSValue=t.CSSValue})),F5=s((e=>{var t={CSSValue:P5().CSSValue};t.CSSValueExpression=function(e,t){this._token=e,this._idx=t},t.CSSValueExpression.prototype=new t.CSSValue,t.CSSValueExpression.prototype.constructor=t.CSSValueExpression,t.CSSValueExpression.prototype.parse=function(){for(var e=this._token,t=this._idx,n=``,r=``,i=``,a,o=[];;++t){if(n=e.charAt(t),n===``){i=`css expression error: unfinished expression!`;break}switch(n){case`(`:o.push(n),r+=n;break;case`)`:o.pop(n),r+=n;break;case`/`:(a=this._parseJSComment(e,t))?a.error?i=`css expression error: unfinished comment in expression!`:t=a.idx:(a=this._parseJSRexExp(e,t))?(t=a.idx,r+=a.text):r+=n;break;case`'`:case`"`:a=this._parseJSString(e,t,n),a?(t=a.idx,r+=a.text):r+=n;break;default:r+=n;break}if(i||o.length===0)break}return i?{error:i}:{idx:t,expression:r}},t.CSSValueExpression.prototype._parseJSComment=function(e,t){var n=e.charAt(t+1),r;if(n===`/`||n===`*`){var i=t,a,o;return n===`/`?o=`
1793
+ `:n===`*`&&(o=`*/`),a=e.indexOf(o,i+1+1),a===-1?{error:`css expression error: unfinished comment in expression!`}:(a=a+o.length-1,r=e.substring(t,a+1),{idx:a,text:r})}else return!1},t.CSSValueExpression.prototype._parseJSString=function(e,t,n){var r=this._findMatchedIdx(e,t,n),i;return r===-1?!1:(i=e.substring(t,r+n.length),{idx:r,text:i})},t.CSSValueExpression.prototype._parseJSRexExp=function(e,t){var n=e.substring(0,t).replace(/\s+$/,``);return[/^$/,/\($/,/\[$/,/\!$/,/\+$/,/\-$/,/\*$/,/\/\s+/,/\%$/,/\=$/,/\>$/,/<$/,/\&$/,/\|$/,/\^$/,/\~$/,/\?$/,/\,$/,/delete$/,/in$/,/instanceof$/,/new$/,/typeof$/,/void$/].some(function(e){return e.test(n)})?this._parseJSString(e,t,`/`):!1},t.CSSValueExpression.prototype._findMatchedIdx=function(e,t,n){for(var r=t,i,a=-1;;)if(i=e.indexOf(n,r+1),i===-1){i=a;break}else{var o=e.substring(t+1,i).match(/\\+$/);if(!o||o[0]%2==0)break;r=i}return e.indexOf(`
1794
+ `,t+1)<i&&(i=a),i},e.CSSValueExpression=t.CSSValueExpression})),I5=s((e=>{var t={};t.MatcherList=function(){this.length=0},t.MatcherList.prototype={constructor:t.MatcherList,get matcherText(){return Array.prototype.join.call(this,`, `)},set matcherText(e){for(var t=e.split(`,`),n=this.length=t.length,r=0;r<n;r++)this[r]=t[r].trim()},appendMatcher:function(e){Array.prototype.indexOf.call(this,e)===-1&&(this[this.length]=e,this.length++)},deleteMatcher:function(e){var t=Array.prototype.indexOf.call(this,e);t!==-1&&Array.prototype.splice.call(this,t,1)}},e.MatcherList=t.MatcherList})),L5=s((e=>{var t={CSSRule:x5().CSSRule,MatcherList:I5().MatcherList};t.CSSDocumentRule=function(){t.CSSRule.call(this),this.matcher=new t.MatcherList,this.cssRules=[]},t.CSSDocumentRule.prototype=new t.CSSRule,t.CSSDocumentRule.prototype.constructor=t.CSSDocumentRule,t.CSSDocumentRule.prototype.type=10,Object.defineProperty(t.CSSDocumentRule.prototype,"cssText",{get:function(){for(var e=[],t=0,n=this.cssRules.length;t<n;t++)e.push(this.cssRules[t].cssText);return`@-moz-document `+this.matcher.matcherText+` {`+e.join(``)+`}`}}),e.CSSDocumentRule=t.CSSDocumentRule})),R5=s((e=>{var t={};t.parse=function(e){for(var n=0,r=`before-selector`,i,a=``,o=0,s={selector:!0,value:!0,"value-parenthesis":!0,atRule:!0,"importRule-begin":!0,importRule:!0,atBlock:!0,conditionBlock:!0,"documentRule-begin":!0},c=new t.CSSStyleSheet,l=c,u,d=[],f=!1,p,m,h=``,g,_,v,y,b,x,S,C,w=/@(-(?:\w+-)+)?keyframes/g,ee=function(t){var r=e.substring(0,n).split(`
1795
+ `),i=r.length,a=r.pop().length+1,o=Error(t+` (line `+i+`, char `+a+`)`);throw o.line=i,o.char=a,o.styleSheet=c,o},te;te=e.charAt(n);n++)switch(te){case` `:case` `:case`\r`:case`
1796
+ `:case`\f`:s[r]&&(a+=te);break;case`"`:i=n+1;do i=e.indexOf(`"`,i)+1,i||ee(`Unmatched "`);while(e[i-2]===`\\`);switch(a+=e.slice(n,i),n=i-1,r){case`before-value`:r=`value`;break;case`importRule-begin`:r=`importRule`;break}break;case`'`:i=n+1;do i=e.indexOf(`'`,i)+1,i||ee(`Unmatched '`);while(e[i-2]===`\\`);switch(a+=e.slice(n,i),n=i-1,r){case`before-value`:r=`value`;break;case`importRule-begin`:r=`importRule`;break}break;case`/`:e.charAt(n+1)===`*`?(n+=2,i=e.indexOf(`*/`,n),i===-1?ee(`Missing */`):n=i+1):a+=te,r===`importRule-begin`&&(a+=` `,r=`importRule`);break;case`@`:if(e.indexOf(`@-moz-document`,n)===n){r=`documentRule-begin`,S=new t.CSSDocumentRule,S.__starts=n,n+=13,a=``;break}else if(e.indexOf(`@media`,n)===n){r=`atBlock`,_=new t.CSSMediaRule,_.__starts=n,n+=5,a=``;break}else if(e.indexOf(`@supports`,n)===n){r=`conditionBlock`,v=new t.CSSSupportsRule,v.__starts=n,n+=8,a=``;break}else if(e.indexOf(`@host`,n)===n){r=`hostRule-begin`,n+=4,C=new t.CSSHostRule,C.__starts=n,a=``;break}else if(e.indexOf(`@import`,n)===n){r=`importRule-begin`,n+=6,a+=`@import`;break}else if(e.indexOf(`@font-face`,n)===n){r=`fontFaceRule-begin`,n+=9,b=new t.CSSFontFaceRule,b.__starts=n,a=``;break}else{w.lastIndex=n;var ne=w.exec(e);if(ne&&ne.index===n){r=`keyframesRule-begin`,x=new t.CSSKeyframesRule,x.__starts=n,x._vendorPrefix=ne[1],n+=ne[0].length-1,a=``;break}else r===`selector`&&(r=`atRule`)}a+=te;break;case`{`:r===`selector`||r===`atRule`?(g.selectorText=a.trim(),g.style.__starts=n,a=``,r=`before-name`):r===`atBlock`?(_.media.mediaText=a.trim(),u&&d.push(u),l=u=_,_.parentStyleSheet=c,a=``,r=`before-selector`):r===`conditionBlock`?(v.conditionText=a.trim(),u&&d.push(u),l=u=v,v.parentStyleSheet=c,a=``,r=`before-selector`):r===`hostRule-begin`?(u&&d.push(u),l=u=C,C.parentStyleSheet=c,a=``,r=`before-selector`):r===`fontFaceRule-begin`?(u&&(b.parentRule=u),b.parentStyleSheet=c,g=b,a=``,r=`before-name`):r===`keyframesRule-begin`?(x.name=a.trim(),u&&(d.push(u),x.parentRule=u),x.parentStyleSheet=c,l=u=x,a=``,r=`keyframeRule-begin`):r===`keyframeRule-begin`?(g=new t.CSSKeyframeRule,g.keyText=a.trim(),g.__starts=n,a=``,r=`before-name`):r===`documentRule-begin`&&(S.matcher.matcherText=a.trim(),u&&(d.push(u),S.parentRule=u),l=u=S,S.parentStyleSheet=c,a=``,r=`before-selector`);break;case`:`:r===`name`?(m=a.trim(),a=``,r=`before-value`):a+=te;break;case`(`:if(r===`value`)if(a.trim()===`expression`){var re=new t.CSSValueExpression(e,n).parse();re.error?ee(re.error):(a+=re.expression,n=re.idx)}else r=`value-parenthesis`,o=1,a+=te;else r===`value-parenthesis`&&o++,a+=te;break;case`)`:r===`value-parenthesis`&&(o--,o===0&&(r=`value`)),a+=te;break;case`!`:r===`value`&&e.indexOf(`!important`,n)===n?(h=`important`,n+=9):a+=te;break;case`;`:switch(r){case`value`:g.style.setProperty(m,a.trim(),h),h=``,a=``,r=`before-name`;break;case`atRule`:a=``,r=`before-selector`;break;case`importRule`:y=new t.CSSImportRule,y.parentStyleSheet=y.styleSheet.parentStyleSheet=c,y.cssText=a+te,c.cssRules.push(y),a=``,r=`before-selector`;break;default:a+=te;break}break;case`}`:switch(r){case`value`:g.style.setProperty(m,a.trim(),h),h=``;case`before-name`:case`name`:g.__ends=n+1,u&&(g.parentRule=u),g.parentStyleSheet=c,l.cssRules.push(g),a=``,r=l.constructor===t.CSSKeyframesRule?`keyframeRule-begin`:`before-selector`;break;case`keyframeRule-begin`:case`before-selector`:case`selector`:for(u||ee(`Unexpected }`),f=d.length>0;d.length>0;){if(u=d.pop(),u.constructor.name===`CSSMediaRule`||u.constructor.name===`CSSSupportsRule`){p=l,l=u,l.cssRules.push(p);break}d.length===0&&(f=!1)}f||(l.__ends=n+1,c.cssRules.push(l),l=c,u=null),a=``,r=`before-selector`;break}break;default:switch(r){case`before-selector`:r=`selector`,g=new t.CSSStyleRule,g.__starts=n;break;case`before-name`:r=`name`;break;case`before-value`:r=`value`;break;case`importRule-begin`:r=`importRule`;break}a+=te;break}return c},e.parse=t.parse,t.CSSStyleSheet=C5().CSSStyleSheet,t.CSSStyleRule=S5().CSSStyleRule,t.CSSImportRule=T5().CSSImportRule,t.CSSGroupingRule=E5().CSSGroupingRule,t.CSSMediaRule=O5().CSSMediaRule,t.CSSConditionRule=D5().CSSConditionRule,t.CSSSupportsRule=k5().CSSSupportsRule,t.CSSFontFaceRule=A5().CSSFontFaceRule,t.CSSHostRule=j5().CSSHostRule,t.CSSStyleDeclaration=z5().CSSStyleDeclaration,t.CSSKeyframeRule=M5().CSSKeyframeRule,t.CSSKeyframesRule=N5().CSSKeyframesRule,t.CSSValueExpression=F5().CSSValueExpression,t.CSSDocumentRule=L5().CSSDocumentRule})),z5=s((e=>{var t={};t.CSSStyleDeclaration=function(){this.length=0,this.parentRule=null,this._importants={}},t.CSSStyleDeclaration.prototype={constructor:t.CSSStyleDeclaration,getPropertyValue:function(e){return this[e]||``},setProperty:function(e,t,n){this[e]?Array.prototype.indexOf.call(this,e)<0&&(this[this.length]=e,this.length++):(this[this.length]=e,this.length++),this[e]=t+``,this._importants[e]=n},removeProperty:function(e){if(!(e in this))return``;var t=Array.prototype.indexOf.call(this,e);if(t<0)return``;var n=this[e];return this[e]=``,Array.prototype.splice.call(this,t,1),n},getPropertyCSSValue:function(){},getPropertyPriority:function(e){return this._importants[e]||``},getPropertyShorthand:function(){},isPropertyImplicit:function(){},get cssText(){for(var e=[],t=0,n=this.length;t<n;++t){var r=this[t],i=this.getPropertyValue(r),a=this.getPropertyPriority(r);a&&=` !`+a,e[t]=r+`: `+i+a+`;`}return e.join(` `)},set cssText(e){var n,r;for(n=this.length;n--;)r=this[n],this[r]=``;Array.prototype.splice.call(this,0,this.length),this._importants={};var i=t.parse(`#bogus{`+e+`}`).cssRules[0].style,a=i.length;for(n=0;n<a;++n)r=i[n],this.setProperty(i[n],i.getPropertyValue(r),i.getPropertyPriority(r))}},e.CSSStyleDeclaration=t.CSSStyleDeclaration,t.parse=R5().parse})),B5=s((e=>{var t={CSSStyleSheet:C5().CSSStyleSheet,CSSRule:x5().CSSRule,CSSStyleRule:S5().CSSStyleRule,CSSGroupingRule:E5().CSSGroupingRule,CSSConditionRule:D5().CSSConditionRule,CSSMediaRule:O5().CSSMediaRule,CSSSupportsRule:k5().CSSSupportsRule,CSSStyleDeclaration:z5().CSSStyleDeclaration,CSSKeyframeRule:M5().CSSKeyframeRule,CSSKeyframesRule:N5().CSSKeyframesRule};t.clone=function e(n){var r=new t.CSSStyleSheet,i=n.cssRules;if(!i)return r;for(var a=0,o=i.length;a<o;a++){var s=i[a],c=r.cssRules[a]=new s.constructor,l=s.style;if(l){for(var u=c.style=new t.CSSStyleDeclaration,d=0,f=l.length;d<f;d++){var p=u[d]=l[d];u[p]=l[p],u._importants[p]=l.getPropertyPriority(p)}u.length=l.length}s.hasOwnProperty(`keyText`)&&(c.keyText=s.keyText),s.hasOwnProperty(`selectorText`)&&(c.selectorText=s.selectorText),s.hasOwnProperty(`mediaText`)&&(c.mediaText=s.mediaText),s.hasOwnProperty(`conditionText`)&&(c.conditionText=s.conditionText),s.hasOwnProperty(`cssRules`)&&(c.cssRules=e(s).cssRules)}return r},e.clone=t.clone})),V5=s((e=>{e.CSSStyleDeclaration=z5().CSSStyleDeclaration,e.CSSRule=x5().CSSRule,e.CSSGroupingRule=E5().CSSGroupingRule,e.CSSConditionRule=D5().CSSConditionRule,e.CSSStyleRule=S5().CSSStyleRule,e.MediaList=w5().MediaList,e.CSSMediaRule=O5().CSSMediaRule,e.CSSSupportsRule=k5().CSSSupportsRule,e.CSSImportRule=T5().CSSImportRule,e.CSSFontFaceRule=A5().CSSFontFaceRule,e.CSSHostRule=j5().CSSHostRule,e.StyleSheet=b5().StyleSheet,e.CSSStyleSheet=C5().CSSStyleSheet,e.CSSKeyframesRule=N5().CSSKeyframesRule,e.CSSKeyframeRule=M5().CSSKeyframeRule,e.MatcherList=I5().MatcherList,e.CSSDocumentRule=L5().CSSDocumentRule,e.CSSValue=P5().CSSValue,e.CSSValueExpression=F5().CSSValueExpression,e.parse=R5().parse,e.clone=B5().clone}))();const H5=`style`;var U5=class extends d5{constructor(e,t=H5){super(e,t),this[A1]=null}get sheet(){let e=this[A1];return e===null?this[A1]=(0,V5.parse)(this.textContent):e}get innerHTML(){return super.innerHTML||``}set innerHTML(e){super.textContent=e,this[A1]=null}get innerText(){return super.innerText||``}set innerText(e){super.textContent=e,this[A1]=null}get textContent(){return super.textContent||``}set textContent(e){super.textContent=e,this[A1]=null}};Z4(H5,U5);var W5=class extends ${constructor(e,t=`time`){super(e,t)}get dateTime(){return Y.get(this,`datetime`)}set dateTime(e){Y.set(this,`datetime`,e)}};Z4(`time`,W5);var G5=class extends ${constructor(e,t=`fieldset`){super(e,t)}},K5=class extends ${constructor(e,t=`embed`){super(e,t)}},q5=class extends ${constructor(e,t=`hr`){super(e,t)}},J5=class extends ${constructor(e,t=`progress`){super(e,t)}},Y5=class extends ${constructor(e,t=`p`){super(e,t)}},X5=class extends ${constructor(e,t=`table`){super(e,t)}},Z5=class extends ${constructor(e,t=`frameset`){super(e,t)}},Q5=class extends ${constructor(e,t=`li`){super(e,t)}},$5=class extends ${constructor(e,t=`base`){super(e,t)}},e7=class extends ${constructor(e,t=`datalist`){super(e,t)}};const t7=`input`;var n7=class extends ${constructor(e,t=t7){super(e,t)}get autofocus(){return f3.get(this,`autofocus`)||-1}set autofocus(e){f3.set(this,`autofocus`,e)}get disabled(){return f3.get(this,`disabled`)}set disabled(e){f3.set(this,`disabled`,e)}get name(){return this.getAttribute(`name`)}set name(e){this.setAttribute(`name`,e)}get placeholder(){return this.getAttribute(`placeholder`)}set placeholder(e){this.setAttribute(`placeholder`,e)}get type(){return this.getAttribute(`type`)}set type(e){this.setAttribute(`type`,e)}get value(){return Y.get(this,`value`)}set value(e){Y.set(this,`value`,e)}};Z4(t7,n7);var r7=class extends ${constructor(e,t=`param`){super(e,t)}},i7=class extends ${constructor(e,t=`media`){super(e,t)}},a7=class extends ${constructor(e,t=`audio`){super(e,t)}},o7=class extends ${constructor(e,t=`h1`){super(e,t)}};Z4([`h1`,`h2`,`h3`,`h4`,`h5`,`h6`],o7);var s7=class extends ${constructor(e,t=`dir`){super(e,t)}},c7=class extends ${constructor(e,t=`quote`){super(e,t)}},l7=c({default:()=>u7}),u7,d7=o((()=>{throw u7={},Error(`Could not resolve "canvas" imported by "linkedom". Is it installed?`)})),f7=s(((e,t)=>{var n=class{constructor(e,t){this.width=e,this.height=t}getContext(){return null}toDataURL(){return``}};t.exports={createCanvas:(e,t)=>new n(e,t)}}));const{createCanvas:p7}=u(s(((e,t)=>{try{t.exports=(d7(),d(l7))}catch{t.exports=f7()}}))(),1).default,m7=`canvas`;var h7=class extends ${constructor(e,t=m7){super(e,t),this[w1]=p7(300,150)}get width(){return this[w1].width}set width(e){p3.set(this,`width`,e),this[w1].width=e}get height(){return this[w1].height}set height(e){p3.set(this,`height`,e),this[w1].height=e}getContext(e){return this[w1].getContext(e)}toDataURL(...e){return this[w1].toDataURL(...e)}};Z4(m7,h7);var g7=class extends ${constructor(e,t=`legend`){super(e,t)}};const _7=`option`;var v7=class extends ${constructor(e,t=_7){super(e,t)}get value(){return Y.get(this,`value`)}set value(e){Y.set(this,`value`,e)}get selected(){return f3.get(this,`selected`)}set selected(e){let t=this.parentElement?.querySelector(`option[selected]`);t&&t!==this&&(t.selected=!1),f3.set(this,`selected`,e)}};Z4(_7,v7);var y7=class extends ${constructor(e,t=`span`){super(e,t)}},b7=class extends ${constructor(e,t=`meter`){super(e,t)}},x7=class extends ${constructor(e,t=`video`){super(e,t)}},S7=class extends ${constructor(e,t=`td`){super(e,t)}};const C7=`title`;var w7=class extends d5{constructor(e,t=C7){super(e,t)}};Z4(C7,w7);var T7=class extends ${constructor(e,t=`output`){super(e,t)}},E7=class extends ${constructor(e,t=`tr`){super(e,t)}},D7=class extends ${constructor(e,t=`data`){super(e,t)}},O7=class extends ${constructor(e,t=`menu`){super(e,t)}};const k7=`select`;var A7=class extends ${constructor(e,t=k7){super(e,t)}get options(){let e=new v3,{firstElementChild:t}=this;for(;t;)t.tagName===`OPTGROUP`?e.push(...t.children):e.push(t),t=t.nextElementSibling;return e}get disabled(){return f3.get(this,`disabled`)}set disabled(e){f3.set(this,`disabled`,e)}get name(){return this.getAttribute(`name`)}set name(e){this.setAttribute(`name`,e)}get value(){return this.querySelector(`option[selected]`)?.value}};Z4(k7,A7);var j7=class extends ${constructor(e,t=`br`){super(e,t)}};const M7=`button`;var N7=class extends ${constructor(e,t=M7){super(e,t)}get disabled(){return f3.get(this,`disabled`)}set disabled(e){f3.set(this,`disabled`,e)}get name(){return this.getAttribute(`name`)}set name(e){this.setAttribute(`name`,e)}get type(){return this.getAttribute(`type`)}set type(e){this.setAttribute(`type`,e)}};Z4(M7,N7);var P7=class extends ${constructor(e,t=`map`){super(e,t)}},F7=class extends ${constructor(e,t=`optgroup`){super(e,t)}},I7=class extends ${constructor(e,t=`dl`){super(e,t)}};const L7=`textarea`;var R7=class extends d5{constructor(e,t=L7){super(e,t)}get disabled(){return f3.get(this,`disabled`)}set disabled(e){f3.set(this,`disabled`,e)}get name(){return this.getAttribute(`name`)}set name(e){this.setAttribute(`name`,e)}get placeholder(){return this.getAttribute(`placeholder`)}set placeholder(e){this.setAttribute(`placeholder`,e)}get type(){return this.getAttribute(`type`)}set type(e){this.setAttribute(`type`,e)}get value(){return this.textContent}set value(e){this.textContent=e}};Z4(L7,R7);var z7=class extends ${constructor(e,t=`font`){super(e,t)}},B7=class extends ${constructor(e,t=`div`){super(e,t)}};const V7=`link`;var H7=class extends ${constructor(e,t=V7){super(e,t)}get disabled(){return f3.get(this,`disabled`)}set disabled(e){f3.set(this,`disabled`,e)}get href(){return Y.get(this,`href`).trim()}set href(e){Y.set(this,`href`,e)}get hreflang(){return Y.get(this,`hreflang`)}set hreflang(e){Y.set(this,`hreflang`,e)}get media(){return Y.get(this,`media`)}set media(e){Y.set(this,`media`,e)}get rel(){return Y.get(this,`rel`)}set rel(e){Y.set(this,`rel`,e)}get type(){return Y.get(this,`type`)}set type(e){Y.set(this,`type`,e)}};Z4(V7,H7);const U7=`slot`;var W7=class extends ${constructor(e,t=U7){super(e,t)}get name(){return this.getAttribute(`name`)}set name(e){this.setAttribute(`name`,e)}assign(){}assignedNodes(e){let t=!!this.name,n=this.getRootNode().host?.childNodes??[],r;if(r=t?[...n].filter(e=>e.slot===this.name):[...n].filter(e=>!e.slot),e?.flatten){let e=[];for(let t of r)t.localName===`slot`?e.push(...t.assignedNodes({flatten:!0})):e.push(t);r=e}return r.length?r:[...this.childNodes]}assignedElements(e){let t=this.assignedNodes(e).filter(e=>e.nodeType===1);return t.length?t:[...this.children]}};Z4(U7,W7);var G7=class extends ${constructor(e,t=`form`){super(e,t)}},K7=class extends ${constructor(e,t=`img`){super(e,t)}get alt(){return Y.get(this,`alt`)}set alt(e){Y.set(this,`alt`,e)}get sizes(){return Y.get(this,`sizes`)}set sizes(e){Y.set(this,`sizes`,e)}get src(){return Y.get(this,`src`)}set src(e){Y.set(this,`src`,e)}get srcset(){return Y.get(this,`srcset`)}set srcset(e){Y.set(this,`srcset`,e)}get title(){return Y.get(this,`title`)}set title(e){Y.set(this,`title`,e)}get width(){return p3.get(this,`width`)}set width(e){p3.set(this,`width`,e)}get height(){return p3.get(this,`height`)}set height(e){p3.set(this,`height`,e)}};Z4(`img`,K7);var q7=class extends ${constructor(e,t=`pre`){super(e,t)}},J7=class extends ${constructor(e,t=`ul`){super(e,t)}};const Y7=`meta`;var X7=class extends ${constructor(e,t=Y7){super(e,t)}get name(){return Y.get(this,`name`)}set name(e){Y.set(this,`name`,e)}get httpEquiv(){return Y.get(this,`http-equiv`)}set httpEquiv(e){Y.set(this,`http-equiv`,e)}get content(){return Y.get(this,`content`)}set content(e){Y.set(this,`content`,e)}get charset(){return Y.get(this,`charset`)}set charset(e){Y.set(this,`charset`,e)}get media(){return Y.get(this,`media`)}set media(e){Y.set(this,`media`,e)}};Z4(Y7,X7);var Z7=class extends ${constructor(e,t=`picture`){super(e,t)}},Q7=class extends ${constructor(e,t=`area`){super(e,t)}},$7=class extends ${constructor(e,t=`ol`){super(e,t)}},e9=class extends ${constructor(e,t=`caption`){super(e,t)}},t9=class extends ${constructor(e,t=`a`){super(e,t)}get href(){return encodeURI(decodeURI(Y.get(this,`href`))).trim()}set href(e){Y.set(this,`href`,decodeURI(e))}get download(){return encodeURI(decodeURI(Y.get(this,`download`)))}set download(e){Y.set(this,`download`,decodeURI(e))}get target(){return Y.get(this,`target`)}set target(e){Y.set(this,`target`,e)}get type(){return Y.get(this,`type`)}set type(e){Y.set(this,`type`,e)}get rel(){return Y.get(this,`rel`)}set rel(e){Y.set(this,`rel`,e)}};Z4(`a`,t9);var n9=class extends ${constructor(e,t=`label`){super(e,t)}},r9=class extends ${constructor(e,t=`unknown`){super(e,t)}},i9=class extends ${constructor(e,t=`mod`){super(e,t)}},a9=class extends ${constructor(e,t=`details`){super(e,t)}};const o9=`source`;var s9=class extends ${constructor(e,t=o9){super(e,t)}get src(){return Y.get(this,`src`)}set src(e){Y.set(this,`src`,e)}get srcset(){return Y.get(this,`srcset`)}set srcset(e){Y.set(this,`srcset`,e)}get sizes(){return Y.get(this,`sizes`)}set sizes(e){Y.set(this,`sizes`,e)}get type(){return Y.get(this,`type`)}set type(e){Y.set(this,`type`,e)}};Z4(o9,s9);const c9={HTMLElement:$,HTMLTemplateElement:c5,HTMLHtmlElement:l5,HTMLScriptElement:p5,HTMLFrameElement:m5,HTMLIFrameElement:g5,HTMLObjectElement:_5,HTMLHeadElement:v5,HTMLBodyElement:y5,HTMLStyleElement:U5,HTMLTimeElement:W5,HTMLFieldSetElement:G5,HTMLEmbedElement:K5,HTMLHRElement:q5,HTMLProgressElement:J5,HTMLParagraphElement:Y5,HTMLTableElement:X5,HTMLFrameSetElement:Z5,HTMLLIElement:Q5,HTMLBaseElement:$5,HTMLDataListElement:e7,HTMLInputElement:n7,HTMLParamElement:r7,HTMLMediaElement:i7,HTMLAudioElement:a7,HTMLHeadingElement:o7,HTMLDirectoryElement:s7,HTMLQuoteElement:c7,HTMLCanvasElement:h7,HTMLLegendElement:g7,HTMLOptionElement:v7,HTMLSpanElement:y7,HTMLMeterElement:b7,HTMLVideoElement:x7,HTMLTableCellElement:S7,HTMLTitleElement:w7,HTMLOutputElement:T7,HTMLTableRowElement:E7,HTMLDataElement:D7,HTMLMenuElement:O7,HTMLSelectElement:A7,HTMLBRElement:j7,HTMLButtonElement:N7,HTMLMapElement:P7,HTMLOptGroupElement:F7,HTMLDListElement:I7,HTMLTextAreaElement:R7,HTMLFontElement:z7,HTMLDivElement:B7,HTMLLinkElement:H7,HTMLSlotElement:W7,HTMLFormElement:G7,HTMLImageElement:K7,HTMLPreElement:q7,HTMLUListElement:J7,HTMLMetaElement:X7,HTMLPictureElement:Z7,HTMLAreaElement:Q7,HTMLOListElement:$7,HTMLTableCaptionElement:e9,HTMLAnchorElement:t9,HTMLLabelElement:n9,HTMLUnknownElement:r9,HTMLModElement:i9,HTMLDetailsElement:a9,HTMLSourceElement:s9,HTMLTrackElement:class extends ${constructor(e,t=`track`){super(e,t)}},HTMLMarqueeElement:class extends ${constructor(e,t=`marquee`){super(e,t)}}},l9={test:()=>!0},u9={"text/html":{docType:`<!DOCTYPE html>`,ignoreCase:!0,voidElements:/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i},"image/svg+xml":{docType:`<?xml version="1.0" encoding="utf-8"?>`,ignoreCase:!1,voidElements:l9},"text/xml":{docType:`<?xml version="1.0" encoding="utf-8"?>`,ignoreCase:!1,voidElements:l9},"application/xml":{docType:`<?xml version="1.0" encoding="utf-8"?>`,ignoreCase:!1,voidElements:l9},"application/xhtml+xml":{docType:`<?xml version="1.0" encoding="utf-8"?>`,ignoreCase:!1,voidElements:l9}};var d9=class extends L8{constructor(e,t={}){super(e,t),this.detail=t.detail}},f9=class extends L8{constructor(e,t={}){super(e,t),this.inputType=t.inputType,this.data=t.data,this.dataTransfer=t.dataTransfer,this.isComposing=t.isComposing||!1,this.ranges=t.ranges}};const p9=e=>class extends K7{constructor(t,n){switch(super(e),arguments.length){case 1:this.height=t,this.width=t;break;case 2:this.height=n,this.width=t;break}}},m9=({[j1]:e,[G]:t},n=null)=>{N4(e[O1],t[K]);do{let r=E4(e),i=r===t?r:r[K];n?n.insertBefore(e,n[G]):e.remove(),e=i}while(e!==t)};var h9=class e{constructor(){this[j1]=null,this[G]=null,this.commonAncestorContainer=null}insertNode(e){this[G].parentNode.insertBefore(e,this[j1])}selectNode(e){this[j1]=e,this[G]=E4(e)}selectNodeContents(e){this.selectNode(e),this.commonAncestorContainer=e}surroundContents(e){e.replaceChildren(this.extractContents())}setStartBefore(e){this[j1]=e}setStartAfter(e){this[j1]=e.nextSibling}setEndBefore(e){this[G]=E4(e.previousSibling)}setEndAfter(e){this[G]=E4(e)}cloneContents(){let{[j1]:e,[G]:t}=this,n=e.ownerDocument.createDocumentFragment();for(;e!==t;)n.insertBefore(e.cloneNode(!0),n[G]),e=E4(e),e!==t&&(e=e[K]);return n}deleteContents(){m9(this)}extractContents(){let e=this[j1].ownerDocument.createDocumentFragment();return m9(this,e),e}createContextualFragment(e){let{commonAncestorContainer:t}=this,n=`ownerSVGElement`in t,r=n?t.ownerDocument:t,i=P4(r,e);if(n){let e=[...i.childNodes];i=r.createDocumentFragment(),Object.setPrototypeOf(i,K8.prototype),i.ownerSVGElement=r;for(let t of e)Object.setPrototypeOf(t,K8.prototype),t.ownerSVGElement=r,i.appendChild(t)}else this.selectNode(i);return i}cloneRange(){let t=new e;return t[j1]=this[j1],t[G]=this[G],t}};const g9=({nodeType:e},t)=>{switch(e){case 1:return t&1;case 3:return t&4;case 8:return t&128;case 4:return t&8}return 0};var _9=class{constructor(e,t=-1){this.root=e,this.currentNode=e,this.whatToShow=t;let{[K]:n,[G]:r}=e;if(e.nodeType===9){let{documentElement:t}=e;n=t,r=t[G]}let i=[];for(;n&&n!==r;)g9(n,t)&&i.push(n),n=n[K];this[k1]={i:0,nodes:i}}nextNode(){let e=this[k1];return this.currentNode=e.i<e.nodes.length?e.nodes[e.i++]:null,this.currentNode}};const v9=(e,t,n)=>{let{[K]:r,[G]:i}=t;return e.call({ownerDocument:t,[K]:r,[G]:i},n)},y9=y4({},a5,c9,{CustomEvent:d9,Event:L8,EventTarget:_3,InputEvent:f9,NamedNodeMap:R8,NodeList:v3}),b9=new WeakMap;var x9=class extends p8{constructor(e){super(null,`#document`,9),this[_1]={active:!1,registry:null},this[E1]={active:!1,class:null},this[T1]=u9[e],this[b1]=null,this[x1]=null,this[C1]=null,this[w1]=null,this[N1]=null}get defaultView(){return b9.has(this)||b9.set(this,new Proxy(globalThis,{set:(e,t,n)=>{switch(t){case`addEventListener`:case`removeEventListener`:case`dispatchEvent`:this[S1][t]=n;break;default:e[t]=n;break}return!0},get:(e,t)=>{switch(t){case`addEventListener`:case`removeEventListener`:case`dispatchEvent`:if(!this[S1]){let e=this[S1]=new _3;e.dispatchEvent=e.dispatchEvent.bind(e),e.addEventListener=e.addEventListener.bind(e),e.removeEventListener=e.removeEventListener.bind(e)}return this[S1][t];case`document`:return this;case`navigator`:return{userAgent:`Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36`};case`window`:return b9.get(this);case`customElements`:return this[_1].registry||(this[_1]=new G4(this)),this[_1];case`performance`:return e.performance;case`DOMParser`:return this[x1];case`Image`:return this[w1]||(this[w1]=p9(this)),this[w1];case`MutationObserver`:return this[E1].class||(this[E1]=new c3(this)),this[E1].class}return this[C1]&&this[C1][t]||y9[t]||e[t]}})),b9.get(this)}get doctype(){let e=this[b1];if(e)return e;let{firstChild:t}=this;return t&&t.nodeType===10?this[b1]=t:null}set doctype(e){if(/^([a-z:]+)(\s+system|\s+public(\s+"([^"]+)")?)?(\s+"([^"]+)")?/i.test(e)){let{$1:e,$4:t,$6:n}=RegExp;this[b1]=new h8(this,e,t,n),j4(this,this[b1],this[K])}}get documentElement(){return this.firstElementChild}get isConnected(){return!0}_getParent(){return this[S1]}createAttribute(e){return new D3(this,e)}createCDATASection(e){return new B3(this,e)}createComment(e){return new V3(this,e)}createDocumentFragment(){return new m8(this)}createDocumentType(e,t,n){return new h8(this,e,t,n)}createElement(e){return new U8(this,e)}createRange(){let e=new h9;return e.commonAncestorContainer=this,e}createTextNode(e){return new l8(this,e)}createTreeWalker(e,t=-1){return new _9(e,t)}createNodeIterator(e,t=-1){return this.createTreeWalker(e,t)}createEvent(e){let t=b4(e===`Event`?new L8(``):new d9(``));return t.initEvent=t.initCustomEvent=(e,n=!1,r=!1,i)=>{t.bubbles=!!n,x4(t,{type:{value:e},canBubble:{value:n},cancelable:{value:r},detail:{value:i}})},t}cloneNode(e=!1){let{constructor:t,[_1]:n,[b1]:r}=this,i=new t;if(i[_1]=n,e){let e=i[G],{childNodes:t}=this;for(let{length:n}=t,r=0;r<n;r++)i.insertBefore(t[r].cloneNode(!0),e);r&&(i[b1]=t[0])}return i}importNode(e){let t=1<arguments.length&&!!arguments[1],n=e.cloneNode(t),{[_1]:r}=this,{active:i}=r,a=e=>{let{ownerDocument:t,nodeType:n}=e;e.ownerDocument=this,i&&t!==this&&n===1&&r.upgrade(e)};if(a(n),t)switch(n.nodeType){case 1:case 11:{let{[K]:e,[G]:t}=n;for(;e!==t;)e.nodeType===1&&a(e),e=e[K];break}}return n}toString(){return this.childNodes.join(``)}querySelector(e){return v9(super.querySelector,this,e)}querySelectorAll(e){return v9(super.querySelectorAll,this,e)}getElementsByTagNameNS(e,t){return this.getElementsByTagName(t)}createAttributeNS(e,t){return this.createAttribute(t)}createElementNS(e,t,n){return e===`http://www.w3.org/2000/svg`?new K8(this,t,null):this.createElement(t,n)}};w4(y9.Document=function(){q8()},x9).prototype=x9.prototype;const S9=(e,t,n,r)=>{if(!t&&X4.has(n))return new(X4.get(n))(e,n);let{[_1]:{active:i,registry:a}}=e;if(i){let i=t?r.is:n;if(a.has(i)){let{Class:t}=a.get(i),r=new t(e,n);return R4.set(r,{connected:!1}),r}}return new $(e,n)};var C9=class extends x9{constructor(){super(`text/html`)}get all(){let e=new v3,{[K]:t,[G]:n}=this;for(;t!==n;){switch(t.nodeType){case 1:e.push(t);break}t=t[K]}return e}get head(){let{documentElement:e}=this,{firstElementChild:t}=e;return(!t||t.tagName!==`HEAD`)&&(t=this.createElement(`head`),e.prepend(t)),t}get body(){let{head:e}=this,{nextElementSibling:t}=e;return(!t||t.tagName!==`BODY`)&&(t=this.createElement(`body`),e.after(t)),t}get title(){let{head:e}=this;return e.getElementsByTagName(`title`).at(0)?.textContent||``}set title(e){let{head:t}=this,n=t.getElementsByTagName(`title`).at(0);n?n.textContent=e:t.insertBefore(this.createElement(`title`),t.firstChild).textContent=e}createElement(e,t){let n=!!(t&&t.is),r=S9(this,n,e,t);return n&&r.setAttribute(`is`,t.is),r}},w9=class extends x9{constructor(){super(`image/svg+xml`)}toString(){return this[T1].docType+super.toString()}},T9=class extends x9{constructor(){super(`text/xml`)}toString(){return this[T1].docType+super.toString()}},E9=class e{parseFromString(t,n,r=null){let i=!1,a;return n===`text/html`?(i=!0,a=new C9):a=n===`image/svg+xml`?new w9:new T9,a[x1]=e,r&&(a[C1]=r),i&&t===`...`&&(t=`<!doctype html><html><head></head><body></body></html>`),t?Y4(a,i,t):a}};const{parse:gee}=JSON,D9=(e,t=null)=>new E9().parseFromString(e,`text/html`,t).defaultView;function O9(){q8()}w4(O9,x9).prototype=x9.prototype;const k9=typeof performance==`object`&&performance&&typeof performance.now==`function`?performance:Date,A9=new Set,j9=typeof process==`object`&&process?process:{},M9=(e,t,n,r)=>{typeof j9.emitWarning==`function`?j9.emitWarning(e,t,n,r):console.error(`[${n}] ${t}: ${e}`)};let N9=globalThis.AbortController,P9=globalThis.AbortSignal;if(N9===void 0){P9=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(e,t){this._onabort.push(t)}},N9=class{constructor(){t()}signal=new P9;abort(e){if(!this.signal.aborted){this.signal.reason=e,this.signal.aborted=!0;for(let t of this.signal._onabort)t(e);this.signal.onabort?.(e)}}};let e=j9.env?.LRU_CACHE_IGNORE_AC_WARNING!==`1`,t=()=>{e&&(e=!1,M9("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.",`NO_ABORT_CONTROLLER`,`ENOTSUP`,t))}}const F9=e=>!A9.has(e),I9=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),L9=e=>I9(e)?e<=2**8?Uint8Array:e<=2**16?Uint16Array:e<=2**32?Uint32Array:e<=2**53-1?R9:null:null;var R9=class extends Array{constructor(e){super(e),this.fill(0)}},z9=class e{heap;length;static#e=!1;static create(t){let n=L9(t);if(!n)return[];e.#e=!0;let r=new e(t,n);return e.#e=!1,r}constructor(t,n){if(!e.#e)throw TypeError(`instantiate Stack using Stack.create(n)`);this.heap=new n(t),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},B9=class e{#e;#t;#n;#r;#i;#a;#o;#s;get perf(){return this.#s}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#c;#l;#u;#d;#f;#p;#m;#h;#g;#_;#v;#y;#b;#x;#S;#C;#w;#T;static unsafeExposeInternals(e){return{starts:e.#b,ttls:e.#x,sizes:e.#y,keyMap:e.#u,keyList:e.#d,valList:e.#f,next:e.#p,prev:e.#m,get head(){return e.#h},get tail(){return e.#g},free:e.#_,isBackgroundFetch:t=>e.#B(t),backgroundFetch:(t,n,r,i)=>e.#z(t,n,r,i),moveToTail:t=>e.#H(t),indexes:t=>e.#F(t),rindexes:t=>e.#I(t),isStale:t=>e.#A(t)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#l}get size(){return this.#c}get fetchMethod(){return this.#a}get memoMethod(){return this.#o}get dispose(){return this.#n}get onInsert(){return this.#r}get disposeAfter(){return this.#i}constructor(t){let{max:n=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:c,dispose:l,onInsert:u,disposeAfter:d,noDisposeOnSet:f,noUpdateTTL:p,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:g,fetchMethod:_,memoMethod:v,noDeleteOnFetchRejection:y,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:S,ignoreFetchAbort:C,perf:w}=t;if(w!==void 0&&typeof w?.now!=`function`)throw TypeError(`perf option must have a now() method if specified`);if(this.#s=w??k9,n!==0&&!I9(n))throw TypeError(`max option must be a nonnegative integer`);let ee=n?L9(n):Array;if(!ee)throw Error(`invalid max value: `+n);if(this.#e=n,this.#t=m,this.maxEntrySize=h||this.#t,this.sizeCalculation=g,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw TypeError(`cannot set sizeCalculation without setting maxSize or maxEntrySize`);if(typeof this.sizeCalculation!=`function`)throw TypeError(`sizeCalculation set to non-function`)}if(v!==void 0&&typeof v!=`function`)throw TypeError(`memoMethod must be a function if defined`);if(this.#o=v,_!==void 0&&typeof _!=`function`)throw TypeError(`fetchMethod must be a function if specified`);if(this.#a=_,this.#C=!!_,this.#u=new Map,this.#d=Array(n).fill(void 0),this.#f=Array(n).fill(void 0),this.#p=new ee(n),this.#m=new ee(n),this.#h=0,this.#g=0,this.#_=z9.create(n),this.#c=0,this.#l=0,typeof l==`function`&&(this.#n=l),typeof u==`function`&&(this.#r=u),typeof d==`function`?(this.#i=d,this.#v=[]):(this.#i=void 0,this.#v=void 0),this.#S=!!this.#n,this.#T=!!this.#r,this.#w=!!this.#i,this.noDisposeOnSet=!!f,this.noUpdateTTL=!!p,this.noDeleteOnFetchRejection=!!y,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!S,this.ignoreFetchAbort=!!C,this.maxEntrySize!==0){if(this.#t!==0&&!I9(this.#t))throw TypeError(`maxSize must be a positive integer if specified`);if(!I9(this.maxEntrySize))throw TypeError(`maxEntrySize must be a positive integer if specified`);this.#j()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=I9(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!I9(this.ttl))throw TypeError(`ttl must be a positive integer if specified`);this.#E()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw TypeError(`At least one of max, maxSize, or ttl is required`);if(!this.ttlAutopurge&&!this.#e&&!this.#t){let t=`LRU_CACHE_UNBOUNDED`;F9(t)&&(A9.add(t),M9(`TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.`,`UnboundedCacheWarning`,t,e))}}getRemainingTTL(e){return this.#u.has(e)?1/0:0}#E(){let e=new R9(this.#e),t=new R9(this.#e);this.#x=e,this.#b=t,this.#k=(n,r,i=this.#s.now())=>{if(t[n]=r===0?0:i,e[n]=r,r!==0&&this.ttlAutopurge){let e=setTimeout(()=>{this.#A(n)&&this.#U(this.#d[n],`expire`)},r+1);e.unref&&e.unref()}},this.#D=n=>{t[n]=e[n]===0?0:this.#s.now()},this.#O=(i,a)=>{if(e[a]){let o=e[a],s=t[a];if(!o||!s)return;i.ttl=o,i.start=s,i.now=n||r(),i.remainingTTL=o-(i.now-s)}};let n=0,r=()=>{let e=this.#s.now();if(this.ttlResolution>0){n=e;let t=setTimeout(()=>n=0,this.ttlResolution);t.unref&&t.unref()}return e};this.getRemainingTTL=i=>{let a=this.#u.get(i);if(a===void 0)return 0;let o=e[a],s=t[a];return!o||!s?1/0:o-((n||r())-s)},this.#A=i=>{let a=t[i],o=e[i];return!!o&&!!a&&(n||r())-a>o}}#D=()=>{};#O=()=>{};#k=()=>{};#A=()=>!1;#j(){let e=new R9(this.#e);this.#l=0,this.#y=e,this.#M=t=>{this.#l-=e[t],e[t]=0},this.#P=(e,t,n,r)=>{if(this.#B(t))return 0;if(!I9(n))if(r){if(typeof r!=`function`)throw TypeError(`sizeCalculation must be a function`);if(n=r(t,e),!I9(n))throw TypeError(`sizeCalculation return invalid (expect positive integer)`)}else throw TypeError(`invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.`);return n},this.#N=(t,n,r)=>{if(e[t]=n,this.#t){let n=this.#t-e[t];for(;this.#l>n;)this.#R(!0)}this.#l+=e[t],r&&(r.entrySize=n,r.totalCalculatedSize=this.#l)}}#M=e=>{};#N=(e,t,n)=>{};#P=(e,t,n,r)=>{if(n||r)throw TypeError(`cannot set size without setting maxSize or maxEntrySize on cache`);return 0};*#F({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#g;!(!this.#L(t)||((e||!this.#A(t))&&(yield t),t===this.#h));)t=this.#m[t]}*#I({allowStale:e=this.allowStale}={}){if(this.#c)for(let t=this.#h;!(!this.#L(t)||((e||!this.#A(t))&&(yield t),t===this.#g));)t=this.#p[t]}#L(e){return e!==void 0&&this.#u.get(this.#d[e])===e}*entries(){for(let e of this.#F())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#B(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*rentries(){for(let e of this.#I())this.#f[e]!==void 0&&this.#d[e]!==void 0&&!this.#B(this.#f[e])&&(yield[this.#d[e],this.#f[e]])}*keys(){for(let e of this.#F()){let t=this.#d[e];t!==void 0&&!this.#B(this.#f[e])&&(yield t)}}*rkeys(){for(let e of this.#I()){let t=this.#d[e];t!==void 0&&!this.#B(this.#f[e])&&(yield t)}}*values(){for(let e of this.#F())this.#f[e]!==void 0&&!this.#B(this.#f[e])&&(yield this.#f[e])}*rvalues(){for(let e of this.#I())this.#f[e]!==void 0&&!this.#B(this.#f[e])&&(yield this.#f[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]=`LRUCache`;find(e,t={}){for(let n of this.#F()){let r=this.#f[n],i=this.#B(r)?r.__staleWhileFetching:r;if(i!==void 0&&e(i,this.#d[n],this))return this.get(this.#d[n],t)}}forEach(e,t=this){for(let n of this.#F()){let r=this.#f[n],i=this.#B(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}rforEach(e,t=this){for(let n of this.#I()){let r=this.#f[n],i=this.#B(r)?r.__staleWhileFetching:r;i!==void 0&&e.call(t,i,this.#d[n],this)}}purgeStale(){let e=!1;for(let t of this.#I({allowStale:!0}))this.#A(t)&&(this.#U(this.#d[t],`expire`),e=!0);return e}info(e){let t=this.#u.get(e);if(t===void 0)return;let n=this.#f[t],r=this.#B(n)?n.__staleWhileFetching:n;if(r===void 0)return;let i={value:r};if(this.#x&&this.#b){let e=this.#x[t],n=this.#b[t];e&&n&&(i.ttl=e-(this.#s.now()-n),i.start=Date.now())}return this.#y&&(i.size=this.#y[t]),i}dump(){let e=[];for(let t of this.#F({allowStale:!0})){let n=this.#d[t],r=this.#f[t],i=this.#B(r)?r.__staleWhileFetching:r;if(i===void 0||n===void 0)continue;let a={value:i};if(this.#x&&this.#b){a.ttl=this.#x[t];let e=this.#s.now()-this.#b[t];a.start=Math.floor(Date.now()-e)}this.#y&&(a.size=this.#y[t]),e.unshift([n,a])}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let e=Date.now()-n.start;n.start=this.#s.now()-e}this.set(t,n.value,n)}}set(e,t,n={}){if(t===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:i,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:s}=n,{noUpdateTTL:c=this.noUpdateTTL}=n,l=this.#P(e,t,n.size||0,o);if(this.maxEntrySize&&l>this.maxEntrySize)return s&&(s.set=`miss`,s.maxEntrySizeExceeded=!0),this.#U(e,`set`),this;let u=this.#c===0?void 0:this.#u.get(e);if(u===void 0)u=this.#c===0?this.#g:this.#_.length===0?this.#c===this.#e?this.#R(!1):this.#c:this.#_.pop(),this.#d[u]=e,this.#f[u]=t,this.#u.set(e,u),this.#p[this.#g]=u,this.#m[u]=this.#g,this.#g=u,this.#c++,this.#N(u,l,s),s&&(s.set=`add`),c=!1,this.#T&&this.#r?.(t,e,`add`);else{this.#H(u);let n=this.#f[u];if(t!==n){if(this.#C&&this.#B(n)){n.__abortController.abort(Error(`replaced`));let{__staleWhileFetching:t}=n;t!==void 0&&!a&&(this.#S&&this.#n?.(t,e,`set`),this.#w&&this.#v?.push([t,e,`set`]))}else a||(this.#S&&this.#n?.(n,e,`set`),this.#w&&this.#v?.push([n,e,`set`]));if(this.#M(u),this.#N(u,l,s),this.#f[u]=t,s){s.set=`replace`;let e=n&&this.#B(n)?n.__staleWhileFetching:n;e!==void 0&&(s.oldValue=e)}}else s&&(s.set=`update`);this.#T&&this.onInsert?.(t,e,t===n?`update`:`replace`)}if(r!==0&&!this.#x&&this.#E(),this.#x&&(c||this.#k(u,r,i),s&&this.#O(s,u)),!a&&this.#w&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return this}pop(){try{for(;this.#c;){let e=this.#f[this.#h];if(this.#R(!0),this.#B(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#w&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}}#R(e){let t=this.#h,n=this.#d[t],r=this.#f[t];return this.#C&&this.#B(r)?r.__abortController.abort(Error(`evicted`)):(this.#S||this.#w)&&(this.#S&&this.#n?.(r,n,`evict`),this.#w&&this.#v?.push([r,n,`evict`])),this.#M(t),e&&(this.#d[t]=void 0,this.#f[t]=void 0,this.#_.push(t)),this.#c===1?(this.#h=this.#g=0,this.#_.length=0):this.#h=this.#p[t],this.#u.delete(n),this.#c--,t}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=t,i=this.#u.get(e);if(i!==void 0){let e=this.#f[i];if(this.#B(e)&&e.__staleWhileFetching===void 0)return!1;if(this.#A(i))r&&(r.has=`stale`,this.#O(r,i));else return n&&this.#D(i),r&&(r.has=`hit`,this.#O(r,i)),!0}else r&&(r.has=`miss`);return!1}peek(e,t={}){let{allowStale:n=this.allowStale}=t,r=this.#u.get(e);if(r===void 0||!n&&this.#A(r))return;let i=this.#f[r];return this.#B(i)?i.__staleWhileFetching:i}#z(e,t,n,r){let i=t===void 0?void 0:this.#f[t];if(this.#B(i))return i;let a=new N9,{signal:o}=n;o?.addEventListener(`abort`,()=>a.abort(o.reason),{signal:a.signal});let s={signal:a.signal,options:n,context:r},c=(r,i=!1)=>{let{aborted:o}=a.signal,c=n.ignoreFetchAbort&&r!==void 0;if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=a.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(a.signal.reason);let l=f;return this.#f[t]===f&&(r===void 0?l.__staleWhileFetching===void 0?this.#U(e,`fetch`):this.#f[t]=l.__staleWhileFetching:(n.status&&(n.status.fetchUpdated=!0),this.set(e,r,s.options))),r},l=e=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=e),u(e)),u=r=>{let{aborted:i}=a.signal,o=i&&n.allowStaleOnFetchAbort,s=o||n.allowStaleOnFetchRejection,c=s||n.noDeleteOnFetchRejection,l=f;if(this.#f[t]===f&&(!c||l.__staleWhileFetching===void 0?this.#U(e,`fetch`):o||(this.#f[t]=l.__staleWhileFetching)),s)return n.status&&l.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),l.__staleWhileFetching;if(l.__returned===l)throw r},d=(t,r)=>{let o=this.#a?.(e,i,s);o&&o instanceof Promise&&o.then(e=>t(e===void 0?void 0:e),r),a.signal.addEventListener(`abort`,()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(t(void 0),n.allowStaleOnFetchAbort&&(t=e=>c(e,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(c,l),p=Object.assign(f,{__abortController:a,__staleWhileFetching:i,__returned:void 0});return t===void 0?(this.set(e,p,{...s.options,status:void 0}),t=this.#u.get(e)):this.#f[t]=p,p}#B(e){if(!this.#C)return!1;let t=e;return!!t&&t instanceof Promise&&t.hasOwnProperty(`__staleWhileFetching`)&&t.__abortController instanceof N9}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:s=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:p=this.allowStaleOnFetchAbort,context:m,forceRefresh:h=!1,status:g,signal:_}=t;if(!this.#C)return g&&(g.fetch=`get`),this.get(e,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});let v={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:a,noDisposeOnSet:o,size:s,sizeCalculation:c,noUpdateTTL:l,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:p,ignoreFetchAbort:f,status:g,signal:_},y=this.#u.get(e);if(y===void 0){g&&(g.fetch=`miss`);let t=this.#z(e,y,v,m);return t.__returned=t}else{let t=this.#f[y];if(this.#B(t)){let e=n&&t.__staleWhileFetching!==void 0;return g&&(g.fetch=`inflight`,e&&(g.returnedStale=!0)),e?t.__staleWhileFetching:t.__returned=t}let i=this.#A(y);if(!h&&!i)return g&&(g.fetch=`hit`),this.#H(y),r&&this.#D(y),g&&this.#O(g,y),t;let a=this.#z(e,y,v,m),o=a.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=i?`stale`:`refresh`,o&&i&&(g.returnedStale=!0)),o?a.__staleWhileFetching:a.__returned=a}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw Error(`fetch() returned undefined`);return n}memo(e,t={}){let n=this.#o;if(!n)throw Error(`no memoMethod provided to constructor`);let{context:r,forceRefresh:i,...a}=t,o=this.get(e,a);if(!i&&o!==void 0)return o;let s=n(e,o,{options:a,context:r});return this.set(e,s,a),s}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:a}=t,o=this.#u.get(e);if(o!==void 0){let t=this.#f[o],s=this.#B(t);return a&&this.#O(a,o),this.#A(o)?(a&&(a.get=`stale`),s?(a&&n&&t.__staleWhileFetching!==void 0&&(a.returnedStale=!0),n?t.__staleWhileFetching:void 0):(i||this.#U(e,`expire`),a&&n&&(a.returnedStale=!0),n?t:void 0)):(a&&(a.get=`hit`),s?t.__staleWhileFetching:(this.#H(o),r&&this.#D(o),t))}else a&&(a.get=`miss`)}#V(e,t){this.#m[t]=e,this.#p[e]=t}#H(e){e!==this.#g&&(e===this.#h?this.#h=this.#p[e]:this.#V(this.#m[e],this.#p[e]),this.#V(this.#g,e),this.#g=e)}delete(e){return this.#U(e,`delete`)}#U(e,t){let n=!1;if(this.#c!==0){let r=this.#u.get(e);if(r!==void 0)if(n=!0,this.#c===1)this.#W(t);else{this.#M(r);let n=this.#f[r];if(this.#B(n)?n.__abortController.abort(Error(`deleted`)):(this.#S||this.#w)&&(this.#S&&this.#n?.(n,e,t),this.#w&&this.#v?.push([n,e,t])),this.#u.delete(e),this.#d[r]=void 0,this.#f[r]=void 0,r===this.#g)this.#g=this.#m[r];else if(r===this.#h)this.#h=this.#p[r];else{let e=this.#m[r];this.#p[e]=this.#p[r];let t=this.#p[r];this.#m[t]=this.#m[r]}this.#c--,this.#_.push(r)}}if(this.#w&&this.#v?.length){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}return n}clear(){return this.#W(`delete`)}#W(e){for(let t of this.#I({allowStale:!0})){let n=this.#f[t];if(this.#B(n))n.__abortController.abort(Error(`deleted`));else{let r=this.#d[t];this.#S&&this.#n?.(n,r,e),this.#w&&this.#v?.push([n,r,e])}}if(this.#u.clear(),this.#f.fill(void 0),this.#d.fill(void 0),this.#x&&this.#b&&(this.#x.fill(0),this.#b.fill(0)),this.#y&&this.#y.fill(0),this.#h=0,this.#g=0,this.#_.length=0,this.#l=0,this.#c=0,this.#w&&this.#v){let e=this.#v,t;for(;t=e?.shift();)this.#i?.(...t)}}};const{window:_ee}=D9(`<!DOCTYPE html><html><body></body></html>`),vee=m1(_ee),V9=new B9({max:1e3}),H9=new B9({max:1e3}),U9=new B9({max:1e3}),W9=e=>{let t=U9.get(e);if(t)return t;let n=GQ.parse(e,{async:!1});return U9.set(e,n),vee.sanitize(n)},G9=e=>{let{document:t}=D9(`<!DOCTYPE html><html><body>${e}</body></html>`);return{innerHTML:t.body?.innerHTML??e,textContent:t.body?.textContent??e}},K9=e=>{let t=V9.get(e);if(t)return t;let n=W9(e),{innerHTML:r,textContent:i}=G9(n);return H9.set(e,i),V9.set(e,r),r},q9=e=>{let t=H9.get(e);if(t)return t;let n=W9(e),{innerHTML:r,textContent:i}=G9(n);return H9.set(e,i),V9.set(e,r),i},yee=zv,bee=VU(`app`),J9={Query:{},Mutation:{},Subscription:{media:{resolve:e=>e,subscribe:async function*(e,t,n){let r=JS(t.input.uri??void 0);if(!r||!(HS(r)||qS(r))){console.warn(`media: refused '${t.input.uri}', which names no uri`);return}let{subscriptions:i,close:a,askOrigins:o,root:s}=rW(n,`MEDIA`),c=XH()===`graph`?gU(r):void 0,l=c?ZL(`view:changed`,{abortSignal:n.request.signal}):QL([`media:changed`,`episode:changed`],{abortSignal:n.request.signal}),u=new Set(QS(r)),d=e=>{let t=QS(e).filter(e=>!u.has(e));if(!t.length)return;for(let e of t)u.add(e);let r=n.params.variables;o(t,{...r,input:{...r?.input,uri:e}})},f=async(e,t)=>{let n=await yU(e,t).catch(e=>(console.error(Error(`media: the placeholder ask failed`,{cause:e})),``));n&&d(n)},p=e=>{e.length&&CG(e,s,{ask:bee,implemented:RU})},m=async()=>{if(c){let e=await c.read();return e?(d(String(e.uri)),f(String(e._id??``),String(e.uri)),FR(r).then(p),e):void 0}let e=await FR(r);if(!e.length)return;let t=fz(e,location.origin);return d(t.uri),p(e),t};try{let e=await m();e&&(yield e);for await(let e of l){if(c&&!c.wakes(e))continue;let t=await m();t&&(yield t)}}finally{a(),await Promise.allSettled(i.map(e=>e.unsubscribe()))}}},mediaPage:{resolve:e=>({nodes:e}),subscribe:async function*(e,t,n){let{subscriptions:r,insertedUris:i,close:a}=rW(n,`MEDIA_PAGE`,e=>e?.data?.mediaPage?.nodes?.map(({uri:e})=>e)),o=XH()===`graph`?oU():void 0,s=new Set,c=o?YL(`view:changed`,e=>{for(let t of e.clusters)s.add(t)}):void 0,l=$L([o?`view:changed`:`media:changed`],100,{abortSignal:n.request.signal}),u=-1,d=async e=>{let n=TG(e,t.input),r=t.input.search;return r&&(n=(await Promise.all(n.map(async e=>({media:e,score:await OT(r,(e.titles??[]).map(e=>e.title))})))).filter(e=>e.score>=.7).sort((e,t)=>t.score-e.score||(t.media.popularity??0)-(e.media.popularity??0)).map(e=>e.media)),DG(n,t.input.sorts)},f=async()=>{let e=[...i];if(o){let t=[...s];s.clear();let n=e.length===u?await o.apply(t,e):await o.read(e);return u=e.length,d(n)}let t=await IR(e.length?e:void 0);return await YG(t)&&(t=await IR(e.length?e:void 0)),t=LR(t),d(t.map(e=>fz(e,location.origin)))};try{yield await f();for await(let e of l)yield await f()}finally{c?.(),a(),await Promise.allSettled(r.map(e=>e.unsubscribe()))}}}},Media:{_id:e=>e._id,categories:e=>e.categories??[],episodes:async e=>{if(XH()===`graph`)return await _U(String(e._id??``));let t=nz(e.handles);if(!t.length)return e.episodes??[];let n=[];for(let e of t)if(n=await AR(e),n.length)break;let r=n.length?await zR(n):await BR(t);if(!r.length)return e.episodes??[];let i=r.flat().filter(e=>e.episodeNumber!=null),a=new Map;for(let e of i)a.has(e.episodeNumber)||a.set(e.episodeNumber,[]),a.get(e.episodeNumber).push(e);return[...a.values()].map(e=>pz(e,location.origin)).sort((e,t)=>(e.episodeNumber??0)-(t.episodeNumber??0))},descriptions:(e,t)=>e.descriptions?.slice(0,t.input?.count?t.input.count:void 0).map(e=>{let n=t.input?.type===NS.Html?K9(e.description):(t.input?.type,NS.Text,q9(e.description));return{...e,shortDescription:n}}),shortDescriptions:(e,t)=>e.shortDescriptions?.slice(0,t.input?.count?t.input.count:void 0)?.map(e=>{let n=t.input?.type===NS.Html?K9(e.shortDescription):(t.input?.type,NS.Text,q9(e.shortDescription));return{...e,shortDescription:n}}).filter(e=>!!e),handles:e=>e.handles??[]}},Y9={Query:{},Mutation:{},Subscription:{},Episode:{handles:e=>e.handles??[],descriptions:(e,t)=>e.descriptions?.slice(0,t.input?.count?t.input.count:void 0).map(e=>{let n=t.input?.type===MS.Html?K9(e.description):(t.input?.type,MS.Text,q9(e.description));return{...e,shortDescription:n}}),shortDescriptions:(e,t)=>e.shortDescriptions?.slice(0,t.input?.count?t.input.count:void 0)?.map(e=>{let n=t.input?.type===MS.Html?K9(e.shortDescription):(t.input?.type,MS.Text,q9(e.shortDescription));return{...e,shortDescription:n}}).filter(e=>!!e)}},X9={Query:{},Mutation:{},Subscription:{}},Z9={Query:{},Mutation:{},Subscription:{origin:{resolve:e=>e,subscribe:async function*(e,t,n){if(!t.input.id)return;let r=WU.map(e=>e.client.subscription(n.params.query,n.params.variables).subscribe(()=>{})),i=await UR(t.input.id);i&&(yield i);let a=ZL(`origin:changed`,{abortSignal:n.request.signal});try{for await(let e of a){let e=await UR(t.input.id);e&&(yield e)}}finally{await Promise.allSettled(r.map(e=>e.unsubscribe()));let e=await UR(t.input.id);if(e)return yield e}}},originPage:{resolve:e=>({nodes:e}),subscribe:async function*(e,t,n){if(!t.input.ids||t.input.ids.length===0)return;let r=WU.map(e=>e.client.subscription(n.params.query,n.params.variables).subscribe(()=>{})),i=t.input.filters?.map(e=>e)??void 0;yield await WR(t.input.ids,i);let a=ZL(`origin:changed`,{abortSignal:n.request.signal});try{for await(let e of a)yield await WR(t.input.ids,i)}finally{return await Promise.allSettled(r.map(e=>e.unsubscribe())),yield await WR(t.input.ids,i)}}}},Origin:{id:e=>e.id,url:e=>e.url,name:e=>e.name,icon:e=>e.icon,color:e=>e.color,isApiOnly:e=>e.isApiOnly}};[Rv,`
1797
+ type Episode {
1798
+ """Stable unique identifier that persists across URI changes and source additions"""
1799
+ _id: String!
1800
+ """Uri consists of the \`origin\` and \`id\` fields in the format \`origin:id\`"""
1801
+ uri: String!
1802
+ """String that is used to target a specific origin, e.g \`google\` or \`yt\` for youtube"""
1803
+ origin: String!
1804
+ """An id that references a specific resource within the origin space"""
1805
+ id: String!
1806
+ """An url to the media resource"""
1807
+ url: String
1808
+ """Uri to the media resource"""
1809
+ mediaUri: String!
1810
+ """Every other row this episode is related to. See \`MediaHandle\` for why the relation is explicit."""
1811
+ handles: [EpisodeHandle!]!
1812
+ score: Float
1813
+ titles: [EpisodeTitle!]!
1814
+ shortDescriptions(input: EpisodeShortDescriptionInput): [EpisodeShortDescription!]!
1815
+ descriptions(input: EpisodeDescriptionInput): [EpisodeDescription!]!
1816
+ releaseDate: Date
1817
+ relativeNumber: Int
1818
+ absoluteNumber: Int
1819
+ thumbnails: [EpisodeThumbnail!]!
1820
+ # playbackSources: [PlaybackSource!]!
1821
+ """URL for an embeddable player iframe"""
1822
+ embedUrl: String
1823
+ seasonNumber: Int
1824
+ episodeNumber: Int
1825
+ absoluteEpisodeNumber: Int
1826
+ """Runtime in minutes"""
1827
+ runtime: Int
1828
+ }
1829
+
1830
+ type EpisodeTitle {
1831
+ language: String!
1832
+ title: String!
1833
+ score: Float
1834
+ }
1835
+
1836
+ input EpisodeShortDescriptionInput {
1837
+ type: EpisodeDescriptionContentType = TEXT
1838
+ count: Int
1839
+ }
1840
+
1841
+ type EpisodeShortDescription {
1842
+ language: String!
1843
+ shortDescription: String!
1844
+ score: Float
1845
+ }
1846
+
1847
+ enum EpisodeDescriptionContentType {
1848
+ HTML
1849
+ TEXT
1850
+ }
1851
+
1852
+ input EpisodeDescriptionInput {
1853
+ type: EpisodeDescriptionContentType = TEXT
1854
+ count: Int
1855
+ }
1856
+
1857
+ type EpisodeDescription {
1858
+ language: String!
1859
+ description: String!
1860
+ score: Float
1861
+ }
1862
+
1863
+
1864
+ type EpisodeThumbnail {
1865
+ language: String
1866
+ url: String!
1867
+ height: Int
1868
+ width: Int
1869
+ """Average #hex color of cover image"""
1870
+ color: String
1871
+ score: Float
1872
+ }
1873
+
1874
+ """
1875
+ One edge out of an episode. Shares \`MediaHandleRelation\` with media on purpose: the two questions are
1876
+ the same question, and a second enum with the same two values would drift.
1877
+ """
1878
+ type EpisodeHandle {
1879
+ """The related row. Carries its own uri, origin, id and url."""
1880
+ node: Episode!
1881
+ """What this edge asserts. Only SAME_AS unions clusters."""
1882
+ relation: MediaHandleRelation!
1883
+ }
1884
+ `,`
1885
+ enum PlaybackSourceType {
1886
+ IFRAME
1887
+ CUSTOM
1888
+ OTHER
1889
+ }
1890
+
1891
+ type PlaybackSource {
1892
+ """Uri consists of the \`origin\` and \`id\` fields in the format \`origin:id\`"""
1893
+ uri: String!
1894
+ """String that is used to target a specific origin, e.g \`google\` or \`yt\` for youtube"""
1895
+ origin: String!
1896
+ """An id that references a specific resource within the origin space"""
1897
+ id: String!
1898
+ """An url to the media resource"""
1899
+ url: String
1900
+ type: PlaybackSourceType!
1901
+ """JSON data for custom players"""
1902
+ data: JSON
1903
+ Episode: Episode
1904
+ }
1905
+ `,yee,`
1906
+ type Origin {
1907
+ """An id to references the origin"""
1908
+ id: String!
1909
+ """An url to the origin"""
1910
+ url: String
1911
+ """The name of the origin"""
1912
+ name: String!
1913
+ """The origin's icon"""
1914
+ icon: String
1915
+ """The origin's color"""
1916
+ color: String
1917
+ """If the origin is an api only origin"""
1918
+ isApiOnly: Boolean!
1919
+ }
1920
+
1921
+ input OriginInput {
1922
+ id: ID!
1923
+ }
1924
+
1925
+ enum OriginFilter {
1926
+ IS_API_ONLY
1927
+ IS_NOT_API_ONLY
1928
+ }
1929
+
1930
+ input OriginPageInput {
1931
+ ids: [ID!]!
1932
+ filters: [OriginFilter!]
1933
+ }
1934
+
1935
+ type OriginPage {
1936
+ """The current page"""
1937
+ firstPageCursor: Id
1938
+ """The current page"""
1939
+ previousPageCursor: Id
1940
+ """The current page"""
1941
+ currentPageCursor: Id
1942
+ """The first page"""
1943
+ nextPageCursor: Id
1944
+ """The last page cursor"""
1945
+ lastPageCursor: Id
1946
+ """Total number of items on the current page"""
1947
+ currentPageNodeCount: Int
1948
+ """The total number of items. Note: This value is not guaranteed to be accurate, do not rely on this for logic"""
1949
+ totalNodeCount: Int
1950
+ """Total number of items before the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic"""
1951
+ beforeCurrentPageNodeCount: Int
1952
+ """Total number of items after the current page. Note: This value is not guaranteed to be accurate, do not rely on this for logic"""
1953
+ afterCurrentPageNodeCount: Int
1954
+ """The media page nodes"""
1955
+ nodes: [Origin!]!
1956
+ }
1957
+
1958
+ extend type Subscription {
1959
+ origin(input: OriginInput!): Origin
1960
+ originPage(input: OriginPageInput!): OriginPage!
1961
+ }
1962
+ `].join(`
1963
+
1964
+ `);const xee={...J9,...Y9,...X9,...Z9,Query:{...J9.Query,...Y9.Query,...X9.Query,...Z9.Query},Mutation:{...J9.Mutation,...Y9.Mutation,...X9.Mutation,...Z9.Mutation},Subscription:{...J9.Subscription,...Y9.Subscription,...X9.Subscription,...Z9.Subscription}},Q9=e=>e.slice(0,e.indexOf(`:`)),$9=(e,t)=>e.uri<t.uri?-1:+(e.uri>t.uri),See=async({excludeOrigins:e,passThroughOrigins:t,uris:n})=>{let r=new Set(e),i=new Set(t??[]),a=U.labeled(`media`),o=U.labeled(`episode`),s=e=>a.has(e)&&!r.has(Q9(e)),c=e=>!i.has(Q9(e)),l=new Set,u=[];for(let e of[...a].sort()){if(l.has(e)||!s(e))continue;l.add(e);let t=[],n=[e];for(;n.length;){let e=n.shift(),r=U.get(e);r&&t.push(r);for(let t of U.neighbours(e,pR.RUN))l.has(t)||!s(t)||(l.add(t),n.push(t))}let i=t.map(e=>e.uri),a=t.filter(e=>c(e.uri));if(!a.some(e=>e.scope!==`CONTAINER`))continue;let d=[],f=new Set;for(let e of t)for(let t of U.targets(e.uri,pR.PART_OF)){let e=[t];for(;e.length;){let t=e.shift();if(f.has(t)||!s(t))continue;f.add(t);let n=U.get(t);n&&c(t)&&d.push(n);for(let n of U.neighbours(t,pR.CONTAINER))e.push(n)}}let p=[],m=new Set;for(let e of t)for(let t of U.targets(e.uri,`has_episode`)){if(m.has(t)||!o.has(t)||r.has(Q9(t))||!c(t))continue;m.add(t);let e=U.get(t);e&&p.push(e)}u.push({walked:i,members:a.sort($9),partOf:d.sort($9),episodes:p.sort($9)})}let d=n&&new Set(n);return{exportedAt:new Date().toISOString(),excludedOrigins:[...r].sort(),clusters:(d?u.filter(e=>e.walked.some(e=>d.has(e))):u).sort((e,t)=>$9(e.members[0],t.members[0])).map(({walked:e,...t})=>t)}},Cee=up({schema:El({typeDefs:Lv,resolvers:xee}),maskedErrors:!1,plugins:[Xl(({errors:e,context:t})=>{for(let n of e)console.error(Error(`GQLError occurred on request: ${t.operationName}`,{cause:n}))}),Rp(),dp()]});Iv({handleRequest:(e,t)=>Cee.handleRequest(new Request(e,t),{}),setUserKeys:e=>TU(e),setGraphEnabled:e=>hZ(e,{scheduler:!0}),setReadStore:async e=>{e===`graph`&&await hZ(!0,{scheduler:!0}),ZH(e)},registerRemoteSource:async(e,t)=>{try{return{ok:await QU(e,t)}}catch(e){return{error:e instanceof Error?e.message:String(e)}}},unregisterRemoteSource:e=>$U(e),exportStore:e=>See({...e,passThroughOrigins:e?.passThroughOrigins??[],excludeOrigins:[...e?.excludeOrigins??[],...WU.filter(e=>e.pluginUri).map(e=>e.extractor.origin)]}),exportAnswers:()=>EH(),exportAsks:()=>cG(),graphCounts:()=>ZX(),traceGraph:e=>dZ(e),traceAnswer:e=>fZ(e),remotePicker:e=>JU(e),remotePlayer:e=>ZU(e),selectRemoteRelease:(e,t)=>YU(e,t)},{transport:globalThis,key:`yoga`});