cable_ready 5.0.0.pre8 → 5.0.0.pre10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2 -542
  3. data/Gemfile +4 -1
  4. data/Gemfile.lock +125 -168
  5. data/IMPLEMENTATION.md +93 -0
  6. data/README.md +36 -10
  7. data/Rakefile +0 -8
  8. data/app/assets/javascripts/cable_ready.js +1265 -0
  9. data/app/assets/javascripts/cable_ready.min.js +2 -0
  10. data/app/assets/javascripts/cable_ready.min.js.map +1 -0
  11. data/app/assets/javascripts/cable_ready.umd.js +1186 -0
  12. data/app/assets/javascripts/cable_ready.umd.min.js +2 -0
  13. data/app/assets/javascripts/cable_ready.umd.min.js.map +1 -0
  14. data/app/channels/cable_ready/stream.rb +7 -5
  15. data/app/helpers/cable_ready/view_helper.rb +58 -0
  16. data/app/jobs/cable_ready_broadcast_job.rb +9 -8
  17. data/app/models/concerns/cable_ready/updatable/collection_updatable_callbacks.rb +2 -0
  18. data/app/models/concerns/cable_ready/updatable/collections_registry.rb +2 -0
  19. data/app/models/concerns/cable_ready/updatable/model_updatable_callbacks.rb +6 -3
  20. data/app/models/concerns/cable_ready/updatable.rb +110 -17
  21. data/app/models/concerns/extend_has_many.rb +2 -0
  22. data/cable_ready.gemspec +40 -0
  23. data/lib/cable_ready/broadcaster.rb +2 -0
  24. data/lib/cable_ready/cable_car.rb +2 -0
  25. data/lib/cable_ready/channel.rb +12 -4
  26. data/lib/cable_ready/channels.rb +3 -1
  27. data/lib/cable_ready/config.rb +16 -2
  28. data/lib/cable_ready/engine.rb +50 -0
  29. data/lib/cable_ready/identifiable.rb +23 -5
  30. data/lib/cable_ready/importmap.rb +4 -0
  31. data/lib/cable_ready/installer.rb +224 -0
  32. data/lib/cable_ready/operation_builder.rb +1 -1
  33. data/lib/cable_ready/sanity_checker.rb +1 -31
  34. data/lib/cable_ready/version.rb +1 -1
  35. data/lib/cable_ready.rb +4 -26
  36. data/lib/cable_ready_helper.rb +13 -0
  37. data/lib/generators/cable_ready/channel_generator.rb +51 -12
  38. data/lib/generators/cable_ready/templates/config/initializers/cable_ready.rb +10 -6
  39. data/lib/install/action_cable.rb +144 -0
  40. data/lib/install/broadcaster.rb +109 -0
  41. data/lib/install/bundle.rb +54 -0
  42. data/lib/install/compression.rb +51 -0
  43. data/lib/install/config.rb +39 -0
  44. data/lib/install/development.rb +34 -0
  45. data/lib/install/esbuild.rb +101 -0
  46. data/lib/install/importmap.rb +96 -0
  47. data/lib/install/initializers.rb +15 -0
  48. data/lib/install/mrujs.rb +121 -0
  49. data/lib/install/npm_packages.rb +13 -0
  50. data/lib/install/shakapacker.rb +61 -0
  51. data/lib/install/spring.rb +54 -0
  52. data/lib/install/updatable.rb +34 -0
  53. data/lib/install/vite.rb +62 -0
  54. data/lib/install/webpacker.rb +81 -0
  55. data/lib/install/yarn.rb +56 -0
  56. data/lib/tasks/cable_ready/cable_ready.rake +249 -0
  57. data/package.json +61 -0
  58. data/rollup.config.mjs +76 -0
  59. data/web-test-runner.config.mjs +12 -0
  60. data/yarn.lock +4623 -0
  61. metadata +96 -129
  62. data/LATEST +0 -1
  63. data/app/helpers/cable_ready_helper.rb +0 -25
  64. data/lib/generators/cable_ready/helpers_generator.rb +0 -43
  65. data/lib/generators/cable_ready/initializer_generator.rb +0 -14
  66. data/test/dummy/app/channels/application_cable/channel.rb +0 -4
  67. data/test/dummy/app/channels/application_cable/connection.rb +0 -4
  68. data/test/dummy/app/controllers/application_controller.rb +0 -2
  69. data/test/dummy/app/helpers/application_helper.rb +0 -2
  70. data/test/dummy/app/jobs/application_job.rb +0 -7
  71. data/test/dummy/app/mailers/application_mailer.rb +0 -4
  72. data/test/dummy/app/models/application_record.rb +0 -3
  73. data/test/dummy/app/models/global_idable_entity.rb +0 -16
  74. data/test/dummy/app/models/post.rb +0 -4
  75. data/test/dummy/app/models/section.rb +0 -6
  76. data/test/dummy/app/models/team.rb +0 -6
  77. data/test/dummy/app/models/topic.rb +0 -4
  78. data/test/dummy/app/models/user.rb +0 -7
  79. data/test/dummy/config/application.rb +0 -22
  80. data/test/dummy/config/boot.rb +0 -5
  81. data/test/dummy/config/environment.rb +0 -5
  82. data/test/dummy/config/environments/development.rb +0 -76
  83. data/test/dummy/config/environments/production.rb +0 -120
  84. data/test/dummy/config/environments/test.rb +0 -59
  85. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
  86. data/test/dummy/config/initializers/assets.rb +0 -12
  87. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -8
  88. data/test/dummy/config/initializers/cable_ready.rb +0 -18
  89. data/test/dummy/config/initializers/content_security_policy.rb +0 -28
  90. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  91. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -6
  92. data/test/dummy/config/initializers/inflections.rb +0 -16
  93. data/test/dummy/config/initializers/mime_types.rb +0 -4
  94. data/test/dummy/config/initializers/permissions_policy.rb +0 -11
  95. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  96. data/test/dummy/config/puma.rb +0 -43
  97. data/test/dummy/config/routes.rb +0 -3
  98. data/test/dummy/db/migrate/20210902154139_create_users.rb +0 -9
  99. data/test/dummy/db/migrate/20210902154153_create_posts.rb +0 -10
  100. data/test/dummy/db/migrate/20210904081930_create_topics.rb +0 -9
  101. data/test/dummy/db/migrate/20210904093607_create_sections.rb +0 -9
  102. data/test/dummy/db/migrate/20210913191735_create_teams.rb +0 -8
  103. data/test/dummy/db/migrate/20210913191759_add_team_reference_to_users.rb +0 -5
  104. data/test/dummy/db/schema.rb +0 -49
  105. data/test/dummy/test/models/post_test.rb +0 -7
  106. data/test/dummy/test/models/section_test.rb +0 -7
  107. data/test/dummy/test/models/team_test.rb +0 -7
  108. data/test/dummy/test/models/topic_test.rb +0 -7
  109. data/test/dummy/test/models/user_test.rb +0 -7
  110. data/test/lib/cable_ready/cable_car_test.rb +0 -50
  111. data/test/lib/cable_ready/compoundable_test.rb +0 -26
  112. data/test/lib/cable_ready/helper_test.rb +0 -25
  113. data/test/lib/cable_ready/identifiable_test.rb +0 -69
  114. data/test/lib/cable_ready/operation_builder_test.rb +0 -189
  115. data/test/lib/cable_ready/updatable_test.rb +0 -112
  116. data/test/lib/generators/cable_ready/channel_generator_test.rb +0 -157
  117. data/test/support/generator_test_helpers.rb +0 -28
  118. data/test/test_helper.rb +0 -18
@@ -0,0 +1,2 @@
1
+ import e from"morphdom";var t="5.0.0-pre10";const n={INPUT:!0,TEXTAREA:!0,SELECT:!0},r={INPUT:!0,TEXTAREA:!0,OPTION:!0},o={"datetime-local":!0,"select-multiple":!0,"select-one":!0,color:!0,date:!0,datetime:!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,textarea:!0,time:!0,url:!0,week:!0};let a;var s={get element(){return a},set(e){a=e}};const i=e=>n[e.tagName]&&o[e.type],l=e=>{const t=(e&&e.nodeType===Node.ELEMENT_NODE?e:document.querySelector(e))||s.element;t&&t.focus&&t.focus()},c=(e,t,n={})=>{const r=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:n});e.dispatchEvent(r),window.jQuery&&window.jQuery(e).trigger(t,n)},u=e=>document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue,d=(e,t=!1)=>{const n=document.evaluate(e,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),r=[];for(let e=0;e<n.snapshotLength;e++)r.push(n.snapshotItem(e));return t?r.reverse():r},m=e=>Array.from(e).flat(),h=(e,t)=>{Array.from(e.selectAll?e.element:[e.element]).forEach(t)},p=(f=function(e,t,n){return e+(n?"-":"")+t.toLowerCase()},function(e){return b(e).reduce(f,"")});var f;const b=e=>(e=null==e?"":e).match(/([A-Z]{2,}|[0-9]+|[A-Z]?[a-z]+|[A-Z])/g)||[],g=(e,t)=>!e.cancel&&(e.delay?setTimeout(t,e.delay):t(),!0),y=(e,t)=>c(e,`cable-ready:before-${p(t.operation)}`,t),w=(e,t)=>c(e,`cable-ready:after-${p(t.operation)}`,t);function E(e,t=250){let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}}function v(e){if(!e.ok)throw Error(e.statusText);return e}function A(e){return void 0===e||["string","number","boolean"].includes(typeof e)||console.warn(`Operation expects a string, number or boolean, but got ${e} (${typeof e})`),null!=e?e:""}function T(e){return void 0!==e&&"string"!=typeof e&&console.warn(`Operation expects a string, but got ${e} (${typeof e})`),null!=e?String(e):""}function S(e){return void 0===e||Array.isArray(e)||console.warn(`Operation expects an array, but got ${e} (${typeof e})`),null!=e?Array.from(e):[]}function C(e){return void 0!==e&&"object"!=typeof e&&console.warn(`Operation expects an object, but got ${e} (${typeof e})`),null!=e?Object(e):{}}function M(e){return void 0===e||Array.isArray(e)||"string"==typeof e||console.warn(`Operation expects an Array or a String, but got ${e} (${typeof e})`),null==e?"":Array.isArray(e)?Array.from(e):String(e)}async function x(e,t){try{const n=await fetch(e,{headers:{"X-REQUESTED-WITH":"XmlHttpRequest",...t}});if(null==n)return;return v(n),n}catch(t){console.error(`Could not fetch ${e}`)}}var O=Object.freeze({__proto__:null,after:w,assignFocus:l,before:y,debounce:E,dispatch:c,fragmentToString:function(e){return(new XMLSerializer).serializeToString(e)},getClassNames:m,graciouslyFetch:x,handleErrors:v,isTextInput:i,kebabize:p,operate:g,processElements:h,safeArray:S,safeObject:C,safeScalar:A,safeString:T,safeStringOrArray:M,xpathToElement:u,xpathToElementArray:d});const L=e=>(t,n)=>!k.map((r=>"function"!=typeof r||r(e,t,n))).includes(!1),$=e=>t=>{q.forEach((n=>{"function"==typeof n&&n(e,t)}))},R=(e,t,n)=>!(!r[t.tagName]&&t.isEqualNode(n)),N=(e,t,n)=>t!==s.element||!t.isContentEditable,U=(e,t,n)=>{const{permanentAttributeName:r}=e;if(!r)return!0;const o=t.closest(`[${r}]`);if(!o&&t===s.element&&i(t)){const e={value:!0};return Array.from(n.attributes).forEach((n=>{e[n.name]||t.setAttribute(n.name,n.value)})),!1}return!o},k=[R,U,N],q=[];var D=Object.freeze({__proto__:null,didMorph:$,didMorphCallbacks:q,shouldMorph:L,shouldMorphCallbacks:k,verifyNotContentEditable:N,verifyNotMutable:R,verifyNotPermanent:U}),P={append:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{html:n,focusSelector:r}=e;t.insertAdjacentHTML("beforeend",A(n)),l(r)})),w(t,e)}))},graft:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{parent:n,focusSelector:r}=e,o=document.querySelector(n);o&&(o.appendChild(t),l(r))})),w(t,e)}))},innerHtml:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{html:n,focusSelector:r}=e;t.innerHTML=A(n),l(r)})),w(t,e)}))},insertAdjacentHtml:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{html:n,position:r,focusSelector:o}=e;t.insertAdjacentHTML(r||"beforeend",A(n)),l(o)})),w(t,e)}))},insertAdjacentText:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{text:n,position:r,focusSelector:o}=e;t.insertAdjacentText(r||"beforeend",A(n)),l(o)})),w(t,e)}))},outerHtml:e=>{h(e,(t=>{const n=t.parentElement,r=n&&Array.from(n.children).indexOf(t);y(t,e),g(e,(()=>{const{html:n,focusSelector:r}=e;t.outerHTML=A(n),l(r)})),w(n?n.children[r]:document.documentElement,e)}))},prepend:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{html:n,focusSelector:r}=e;t.insertAdjacentHTML("afterbegin",A(n)),l(r)})),w(t,e)}))},remove:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{focusSelector:n}=e;t.remove(),l(n)})),w(document,e)}))},replace:e=>{h(e,(t=>{const n=t.parentElement,r=n&&Array.from(n.children).indexOf(t);y(t,e),g(e,(()=>{const{html:n,focusSelector:r}=e;t.outerHTML=A(n),l(r)})),w(n?n.children[r]:document.documentElement,e)}))},textContent:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{text:n,focusSelector:r}=e;t.textContent=A(n),l(r)})),w(t,e)}))},addCssClass:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n}=e;t.classList.add(...m([M(n)]))})),w(t,e)}))},removeAttribute:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n}=e;t.removeAttribute(T(n))})),w(t,e)}))},removeCssClass:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n}=e;t.classList.remove(...m([M(n)])),0===t.classList.length&&t.removeAttribute("class")})),w(t,e)}))},setAttribute:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n,value:r}=e;t.setAttribute(T(n),A(r))})),w(t,e)}))},setDatasetProperty:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n,value:r}=e;t.dataset[T(n)]=A(r)})),w(t,e)}))},setProperty:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n,value:r}=e;n in t&&(t[T(n)]=A(r))})),w(t,e)}))},setStyle:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n,value:r}=e;t.style[T(n)]=A(r)})),w(t,e)}))},setStyles:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{styles:n}=e;for(let[e,r]of Object.entries(n))t.style[T(e)]=A(r)})),w(t,e)}))},setValue:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{value:n}=e;t.value=A(n)})),w(t,e)}))},dispatchEvent:e=>{h(e,(t=>{y(t,e),g(e,(()=>{const{name:n,detail:r}=e;c(t,T(n),C(r))})),w(t,e)}))},setMeta:e=>{y(document,e),g(e,(()=>{const{name:t,content:n}=e;let r=document.head.querySelector(`meta[name='${t}']`);r||(r=document.createElement("meta"),r.name=T(t),document.head.appendChild(r)),r.content=A(n)})),w(document,e)},setTitle:e=>{y(document,e),g(e,(()=>{const{title:t}=e;document.title=A(t)})),w(document,e)},clearStorage:e=>{y(document,e),g(e,(()=>{const{type:t}=e;("session"===t?sessionStorage:localStorage).clear()})),w(document,e)},go:e=>{y(window,e),g(e,(()=>{const{delta:t}=e;history.go(t)})),w(window,e)},pushState:e=>{y(window,e),g(e,(()=>{const{state:t,title:n,url:r}=e;history.pushState(C(t),T(n),T(r))})),w(window,e)},redirectTo:e=>{y(window,e),g(e,(()=>{let{url:t,action:n,turbo:r}=e;n=n||"advance",t=T(t),void 0===r&&(r=!0),r?(window.Turbo&&window.Turbo.visit(t,{action:n}),window.Turbolinks&&window.Turbolinks.visit(t,{action:n}),window.Turbo||window.Turbolinks||(window.location.href=t)):window.location.href=t})),w(window,e)},reload:e=>{y(window,e),g(e,(()=>{window.location.reload()})),w(window,e)},removeStorageItem:e=>{y(document,e),g(e,(()=>{const{key:t,type:n}=e;("session"===n?sessionStorage:localStorage).removeItem(T(t))})),w(document,e)},replaceState:e=>{y(window,e),g(e,(()=>{const{state:t,title:n,url:r}=e;history.replaceState(C(t),T(n),T(r))})),w(window,e)},scrollIntoView:e=>{const{element:t}=e;y(t,e),g(e,(()=>{t.scrollIntoView(e)})),w(t,e)},setCookie:e=>{y(document,e),g(e,(()=>{const{cookie:t}=e;document.cookie=A(t)})),w(document,e)},setFocus:e=>{const{element:t}=e;y(t,e),g(e,(()=>{l(t)})),w(t,e)},setStorageItem:e=>{y(document,e),g(e,(()=>{const{key:t,value:n,type:r}=e;("session"===r?sessionStorage:localStorage).setItem(T(t),A(n))})),w(document,e)},consoleLog:e=>{y(document,e),g(e,(()=>{const{message:t,level:n}=e;n&&["warn","info","error"].includes(n)?console[n](t):console.log(t)})),w(document,e)},consoleTable:e=>{y(document,e),g(e,(()=>{const{data:t,columns:n}=e;console.table(t,S(n))})),w(document,e)},notification:e=>{y(document,e),g(e,(()=>{const{title:t,options:n}=e;Notification.requestPermission().then((r=>{e.permission=r,"granted"===r&&new Notification(T(t),C(n))}))})),w(document,e)},morph:t=>{h(t,(n=>{const{html:r}=t,o=document.createElement("template");o.innerHTML=String(A(r)).trim(),t.content=o.content;const a=n.parentElement,s=a&&Array.from(a.children).indexOf(n);y(n,t),g(t,(()=>{const{childrenOnly:r,focusSelector:a}=t;e(n,r?o.content:o.innerHTML,{childrenOnly:!!r,onBeforeElUpdated:L(t),onElUpdated:$(t)}),l(a)})),w(a?a.children[s]:document.documentElement,t)}))}};let _=P;const H=e=>{_={..._,...e}};var I={get all(){return _}};let j="warn";var z={get behavior(){return j},set(e){["warn","ignore","event","exception"].includes(e)?j=e:console.warn("Invalid 'onMissingElement' option. Defaulting to 'warn'.")}};const F=(e,t={onMissingElement:z.behavior})=>{const n={};e.forEach((e=>{e.batch&&(n[e.batch]=n[e.batch]?++n[e.batch]:1)})),e.forEach((e=>{const r=e.operation;try{if(e.selector?e.xpath?e.element=e.selectAll?d(e.selector):u(e.selector):e.element=e.selectAll?document.querySelectorAll(e.selector):document.querySelector(e.selector):e.element=document,e.element||"ignore"!==t.onMissingElement){s.set(document.activeElement);const t=I.all[r];t?(t(e),e.batch&&0==--n[e.batch]&&c(document,"cable-ready:batch-complete",{batch:e.batch})):console.error(`CableReady couldn't find the "${r}" operation. Make sure you use the camelized form when calling an operation method.`)}}catch(n){if(e.element)console.error(`CableReady detected an error in ${r||"operation"}: ${n.message}. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`),console.error(n);else{const n=`CableReady ${r||""} operation failed due to missing DOM element for selector: '${e.selector}'`;switch(t.onMissingElement){case"ignore":break;case"event":c(document,"cable-ready:missing-element",{warning:n,operation:e});break;case"exception":throw n;default:console.warn(n)}}}}))};class X extends HTMLElement{static get tagName(){throw new Error("Implement the tagName() getter in the inheriting class")}static define(){customElements.get(this.tagName)||customElements.define(this.tagName,this)}disconnectedCallback(){this.channel&&this.channel.unsubscribe()}createSubscription(e,t,n){this.channel=e.subscriptions.create({channel:t,identifier:this.identifier},{received:n})}get preview(){return document.documentElement.hasAttribute("data-turbolinks-preview")||document.documentElement.hasAttribute("data-turbo-preview")}get identifier(){return this.getAttribute("identifier")}}let V;const Y=[25,50,75,100,200,250,500,800,1e3,2e3],Q=async(e=0)=>{if(V)return V;if(e>=Y.length)throw new Error("Couldn't obtain a Action Cable consumer within 5s");var t;return await(t=Y[e],new Promise((e=>setTimeout(e,t)))),await Q(e+1)};var Z={setConsumer(e){V=e},get consumer(){return V},getConsumer:async()=>await Q()};class B extends X{static get tagName(){return"cable-ready-stream-from"}async connectedCallback(){if(this.preview)return;const e=await Z.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.performOperations.bind(this)):console.error("The `cable_ready_stream_from` helper cannot connect. You must initialize CableReady with an Action Cable consumer.")}performOperations(e){e.cableReady&&F(e.operations,{onMissingElement:this.onMissingElement})}get onMissingElement(){const e=this.getAttribute("missing")||z.behavior;return["warn","ignore","event"].includes(e)?e:(console.warn("Invalid 'missing' attribute. Defaulting to 'warn'."),"warn")}}let W=!1;var G={get enabled(){return W},get disabled(){return!W},get value(){return W},set(e){W=!!e},set debug(e){W=!!e}};var J=(e,t)=>{G.disabled||console.log(`↑ Updatable request affecting ${t.length} element(s): `,{elements:t.map((e=>e.element)),identifiers:t.map((e=>e.element.getAttribute("identifier"))),data:e})},K=(e,t)=>{if(G.disabled)return;const n=new Date-e;console.log(`❌ Updatable request canceled after ${n}ms: ${t}`)},ee=(e,t,n)=>{if(G.disabled)return;const r=new Date-e;console.log(`↓ Updatable response: All URLs fetched in ${r}ms`,{element:t,urls:n})},te=(e,t)=>{if(G.disabled)return;const n=new Date-e;console.log(`↻ Updatable morph: starting after ${n}ms`,{element:t})},ne=(e,t)=>{if(G.disabled)return;const n=new Date-e;console.log(`↺ Updatable morph: completed after ${n}ms`,{element:t})};class re extends X{static get tagName(){return"cable-ready-updates-for"}constructor(){super();this.attachShadow({mode:"open"}).innerHTML="\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n"}async connectedCallback(){if(this.preview)return;this.update=E(this.update.bind(this),this.debounce);const e=await Z.getConsumer();e?this.createSubscription(e,"CableReady::Stream",this.update):console.error("The `cable_ready_updates_for` helper cannot connect. You must initialize CableReady with an Action Cable consumer.")}async update(e){this.lastUpdateTimestamp=new Date;const t=Array.from(document.querySelectorAll(this.query),(e=>new oe(e))).filter((t=>t.shouldUpdate(e)));if(J(e,t),0===t.length)return void K(this.lastUpdateTimestamp,"All elements filtered out");if(t[0].element!==this)return void K(this.lastUpdateTimestamp,"Update already requested");s.set(document.activeElement),this.html={};const n=[...new Set(t.map((e=>e.url)))];await Promise.all(n.map((async e=>{if(!this.html.hasOwnProperty(e)){const t=await x(e,{"X-Cable-Ready":"update"});this.html[e]=await t.text()}}))),ee(this.lastUpdateTimestamp,this,n),this.index={},t.forEach((t=>{this.index.hasOwnProperty(t.url)?this.index[t.url]++:this.index[t.url]=0,t.process(e,this.html,this.index,this.lastUpdateTimestamp)}))}get query(){return`${this.tagName}[identifier="${this.identifier}"]`}get identifier(){return this.getAttribute("identifier")}get debounce(){return this.hasAttribute("debounce")?parseInt(this.getAttribute("debounce")):20}}class oe{constructor(e){this.element=e}async process(t,n,r,o){const a=r[this.url],s=document.createElement("template");this.element.setAttribute("updating","updating"),s.innerHTML=String(n[this.url]).trim(),await this.resolveTurboFrames(s.content);const i=s.content.querySelectorAll(this.query);if(i.length<=a)return void console.warn(`Update aborted due to insufficient number of elements. The offending url is ${this.url}.`);const u={element:this.element,html:i[a],permanentAttributeName:"data-ignore-updates"};c(this.element,"cable-ready:before-update",u),te(o,this.element),e(this.element,i[a],{childrenOnly:!0,onBeforeElUpdated:L(u),onElUpdated:e=>{this.element.removeAttribute("updating"),c(this.element,"cable-ready:after-update",u),l(u.focusSelector)}}),ne(o,this.element)}async resolveTurboFrames(e){const t=[...e.querySelectorAll('turbo-frame[src]:not([loading="lazy"])')];return Promise.all(t.map((e=>new Promise((async t=>{const n=await x(e.getAttribute("src"),{"Turbo-Frame":e.id,"X-Cable-Ready":"update"}),r=document.createElement("template");r.innerHTML=await n.text(),await this.resolveTurboFrames(r.content);const o=`turbo-frame#${e.id}`,a=r.content.querySelector(o),s=a?a.innerHTML.trim():"";docFragment.querySelector(o).innerHTML=s,t()})))))}shouldUpdate(e){return!this.ignoresInnerUpdates&&this.hasChangesSelectedForUpdate(e)}hasChangesSelectedForUpdate(e){const t=this.element.getAttribute("only");return!(t&&e.changed&&!t.split(" ").some((t=>e.changed.includes(t))))}get ignoresInnerUpdates(){return this.element.hasAttribute("ignore-inner-updates")&&this.element.hasAttribute("performing-inner-update")}get url(){return this.element.hasAttribute("url")?this.element.getAttribute("url"):location.href}get identifier(){return this.element.identifier}get query(){return this.element.query}}const ae=e=>{const t=e&&e.parentElement&&e.parentElement.closest("cable-ready-updates-for");t&&(t.setAttribute("performing-inner-update",""),ae(t))},se=e=>{const t=e&&e.parentElement&&e.parentElement.closest("cable-ready-updates-for");t&&(t.removeAttribute("performing-inner-update"),se(t))},ie=()=>{document.addEventListener("stimulus-reflex:before",(e=>{ae(e.detail.element)})),document.addEventListener("stimulus-reflex:after",(e=>{setTimeout((()=>{se(e.detail.element)}))})),document.addEventListener("turbo:submit-start",(e=>{ae(e.target)})),document.addEventListener("turbo:submit-end",(e=>{setTimeout((()=>{se(e.target)}))})),document.addEventListener("turbo-boost:command:start",(e=>{ae(e.target)})),document.addEventListener("turbo-boost:command:finish",(e=>{setTimeout((()=>{se(e.target)}))})),document.addEventListener("turbo-boost:command:error",(e=>{setTimeout((()=>{se(e.target)}))})),B.define(),re.define()},le={perform:F,performAsync:(e,t={onMissingElement:z.behavior})=>new Promise(((n,r)=>{try{n(F(e,t))}catch(e){r(e)}})),shouldMorphCallbacks:k,didMorphCallbacks:q,initialize:(e={})=>{const{consumer:t,onMissingElement:n,debug:r}=e;G.set(!!r),t?Z.setConsumer(t):console.error("CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`."),n&&MissingElement.set(n),ie()},addOperation:(e,t)=>{const n={};n[e]=t,H(n)},addOperations:e=>{H(e)},version:t,cable:Z,get DOMOperations(){return console.warn("DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`"),I.all},get operations(){return I.all},get consumer(){return Z.consumer}};window.CableReady=le;export{D as MorphCallbacks,B as StreamFromElement,X as SubscribingElement,re as UpdatesForElement,O as Utils,le as default};
2
+ //# sourceMappingURL=cable_ready.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cable_ready.min.js","sources":["../../../javascript/enums.js","../../../javascript/active_element.js","../../../javascript/utils.js","../../../javascript/morph_callbacks.js","../../../javascript/operations.js","../../../javascript/operation_store.js","../../../javascript/missing_element.js","../../../javascript/cable_ready.js","../../../javascript/elements/subscribing_element.js","../../../javascript/cable_consumer.js","../../../javascript/elements/stream_from_element.js","../../../javascript/debug.js","../../../javascript/updatable/log.js","../../../javascript/elements/updates_for_element.js","../../../javascript/updatable/inner_updates_compat.js","../../../javascript/elements/index.js","../../../javascript/index.js"],"sourcesContent":["export const inputTags = {\n INPUT: true,\n TEXTAREA: true,\n SELECT: true\n}\n\nexport const mutableTags = {\n INPUT: true,\n TEXTAREA: true,\n OPTION: true\n}\n\nexport const textInputTypes = {\n 'datetime-local': true,\n 'select-multiple': true,\n 'select-one': true,\n color: true,\n date: true,\n datetime: true,\n email: true,\n month: true,\n number: true,\n password: true,\n range: true,\n search: true,\n tel: true,\n text: true,\n textarea: true,\n time: true,\n url: true,\n week: true\n}\n","let activeElement\n\nexport default {\n get element () {\n return activeElement\n },\n set (element) {\n activeElement = element\n }\n}\n","import { inputTags, textInputTypes } from './enums'\nimport ActiveElement from './active_element'\n\n// Indicates if the passed element is considered a text input.\n//\nconst isTextInput = element => {\n return inputTags[element.tagName] && textInputTypes[element.type]\n}\n\n// Assigns focus to the appropriate element... preferring the explicitly passed selector\n//\n// * selector - a CSS selector for the element that should have focus\n//\nconst assignFocus = selector => {\n const element =\n selector && selector.nodeType === Node.ELEMENT_NODE\n ? selector\n : document.querySelector(selector)\n const focusElement = element || ActiveElement.element\n if (focusElement && focusElement.focus) focusElement.focus()\n}\n\n// Dispatches an event on the passed element\n//\n// * element - the element\n// * name - the name of the event\n// * detail - the event detail\n//\nconst dispatch = (element, name, detail = {}) => {\n const init = { bubbles: true, cancelable: true, detail }\n const event = new CustomEvent(name, init)\n element.dispatchEvent(event)\n if (window.jQuery) window.jQuery(element).trigger(name, detail)\n}\n\n// Accepts an xPath query and returns the element found at that position in the DOM\n//\nconst xpathToElement = xpath => {\n return document.evaluate(\n xpath,\n document,\n null,\n XPathResult.FIRST_ORDERED_NODE_TYPE,\n null\n ).singleNodeValue\n}\n\n// Accepts an xPath query and returns all matching elements in the DOM\n//\nconst xpathToElementArray = (xpath, reverse = false) => {\n const snapshotList = document.evaluate(\n xpath,\n document,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n )\n const snapshots = []\n\n for (let i = 0; i < snapshotList.snapshotLength; i++) {\n snapshots.push(snapshotList.snapshotItem(i))\n }\n\n return reverse ? snapshots.reverse() : snapshots\n}\n\n// Return an array with the class names to be used\n//\n// * names - could be a string or an array of strings for multiple classes.\n//\nconst getClassNames = names => Array.from(names).flat()\n\n// Perform operation for either the first or all of the elements returned by CSS selector\n//\n// * operation - the instruction payload from perform\n// * callback - the operation function to run for each element\n//\nconst processElements = (operation, callback) => {\n Array.from(\n operation.selectAll ? operation.element : [operation.element]\n ).forEach(callback)\n}\n\n// convert string to kebab-case\n// most other implementations (lodash) are focused on camelCase to kebab-case\n// instead, this uses word token boundaries to produce readable URL slugs and keys\n// this implementation will not support Emoji or other non-ASCII characters\n//\nconst kebabize = createCompounder(function (result, word, index) {\n return result + (index ? '-' : '') + word.toLowerCase()\n})\n\nfunction createCompounder (callback) {\n return function (str) {\n return words(str).reduce(callback, '')\n }\n}\n\nconst words = str => {\n str = str == null ? '' : str\n return str.match(/([A-Z]{2,}|[0-9]+|[A-Z]?[a-z]+|[A-Z])/g) || []\n}\n\n// Provide a standardized pipeline of checks and modifications to all operations based on provided options\n// Currently skips execution if cancelled and implements an optional delay\n//\nconst operate = (operation, callback) => {\n if (!operation.cancel) {\n operation.delay ? setTimeout(callback, operation.delay) : callback()\n return true\n }\n return false\n}\n\n// Dispatch life-cycle events with standardized naming\nconst before = (target, operation) =>\n dispatch(\n target,\n `cable-ready:before-${kebabize(operation.operation)}`,\n operation\n )\n\nconst after = (target, operation) =>\n dispatch(\n target,\n `cable-ready:after-${kebabize(operation.operation)}`,\n operation\n )\n\nfunction debounce (fn, delay = 250) {\n let timer\n return (...args) => {\n const callback = () => fn.apply(this, args)\n if (timer) clearTimeout(timer)\n timer = setTimeout(callback, delay)\n }\n}\n\nfunction handleErrors (response) {\n if (!response.ok) throw Error(response.statusText)\n return response\n}\n\nfunction safeScalar (val) {\n if (\n val !== undefined &&\n !['string', 'number', 'boolean'].includes(typeof val)\n )\n console.warn(\n `Operation expects a string, number or boolean, but got ${val} (${typeof val})`\n )\n return val != null ? val : ''\n}\n\nfunction safeString (str) {\n if (str !== undefined && typeof str !== 'string')\n console.warn(`Operation expects a string, but got ${str} (${typeof str})`)\n\n return str != null ? String(str) : ''\n}\n\nfunction safeArray (arr) {\n if (arr !== undefined && !Array.isArray(arr))\n console.warn(`Operation expects an array, but got ${arr} (${typeof arr})`)\n return arr != null ? Array.from(arr) : []\n}\n\nfunction safeObject (obj) {\n if (obj !== undefined && typeof obj !== 'object')\n console.warn(`Operation expects an object, but got ${obj} (${typeof obj})`)\n return obj != null ? Object(obj) : {}\n}\n\nfunction safeStringOrArray (elem) {\n if (elem !== undefined && !Array.isArray(elem) && typeof elem !== 'string')\n console.warn(`Operation expects an Array or a String, but got ${elem} (${typeof elem})`)\n\n return elem == null ? '' : Array.isArray(elem) ? Array.from(elem) : String(elem)\n}\n\nfunction fragmentToString (fragment) {\n return new XMLSerializer().serializeToString(fragment)\n}\n\n// A proxy method to wrap a fetch call in error handling\n//\n// * url - the URL to fetch\n// * additionalHeaders - an object of additional headers passed to fetch\n//\nasync function graciouslyFetch (url, additionalHeaders) {\n try {\n const response = await fetch(url, {\n headers: {\n 'X-REQUESTED-WITH': 'XmlHttpRequest',\n ...additionalHeaders\n }\n })\n if (response == undefined) return\n\n handleErrors(response)\n\n return response\n } catch (e) {\n console.error(`Could not fetch ${url}`)\n }\n}\n\nexport {\n isTextInput,\n assignFocus,\n dispatch,\n xpathToElement,\n xpathToElementArray,\n getClassNames,\n processElements,\n operate,\n before,\n after,\n debounce,\n handleErrors,\n graciouslyFetch,\n kebabize,\n safeScalar,\n safeString,\n safeArray,\n safeObject,\n safeStringOrArray,\n fragmentToString\n}\n","import { mutableTags } from './enums'\nimport { isTextInput } from './utils'\nimport ActiveElement from './active_element'\n\n// Indicates whether or not we should morph an element via onBeforeElUpdated callback\n// SEE: https://github.com/patrick-steele-idem/morphdom#morphdomfromnode-tonode-options--node\n//\nconst shouldMorph = operation => (fromEl, toEl) => {\n return !shouldMorphCallbacks\n .map(callback => {\n return typeof callback === 'function'\n ? callback(operation, fromEl, toEl)\n : true\n })\n .includes(false)\n}\n\n// Execute any pluggable functions that modify elements after morphing via onElUpdated callback\n//\nconst didMorph = operation => el => {\n didMorphCallbacks.forEach(callback => {\n if (typeof callback === 'function') callback(operation, el)\n })\n}\n\nconst verifyNotMutable = (detail, fromEl, toEl) => {\n // Skip nodes that are equal:\n // https://github.com/patrick-steele-idem/morphdom#can-i-make-morphdom-blaze-through-the-dom-tree-even-faster-yes\n if (!mutableTags[fromEl.tagName] && fromEl.isEqualNode(toEl)) return false\n return true\n}\n\nconst verifyNotContentEditable = (detail, fromEl, toEl) => {\n if (fromEl === ActiveElement.element && fromEl.isContentEditable) return false\n return true\n}\n\nconst verifyNotPermanent = (detail, fromEl, toEl) => {\n const { permanentAttributeName } = detail\n if (!permanentAttributeName) return true\n\n const permanent = fromEl.closest(`[${permanentAttributeName}]`)\n\n // only morph attributes on the active non-permanent text input\n if (!permanent && fromEl === ActiveElement.element && isTextInput(fromEl)) {\n const ignore = { value: true }\n Array.from(toEl.attributes).forEach(attribute => {\n if (!ignore[attribute.name])\n fromEl.setAttribute(attribute.name, attribute.value)\n })\n return false\n }\n\n return !permanent\n}\n\nconst shouldMorphCallbacks = [\n verifyNotMutable,\n verifyNotPermanent,\n verifyNotContentEditable\n]\nconst didMorphCallbacks = []\n\nexport {\n shouldMorphCallbacks,\n didMorphCallbacks,\n shouldMorph,\n didMorph,\n verifyNotMutable,\n verifyNotContentEditable,\n verifyNotPermanent\n}\n","import morphdom from 'morphdom'\n\nimport { shouldMorph, didMorph } from './morph_callbacks'\nimport {\n assignFocus,\n dispatch,\n getClassNames,\n processElements,\n before,\n after,\n operate,\n safeScalar,\n safeString,\n safeArray,\n safeObject,\n safeStringOrArray\n} from './utils'\n\nexport default {\n // DOM Mutations\n\n append: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.insertAdjacentHTML('beforeend', safeScalar(html))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n graft: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { parent, focusSelector } = operation\n const parentElement = document.querySelector(parent)\n if (parentElement) {\n parentElement.appendChild(element)\n assignFocus(focusSelector)\n }\n })\n after(element, operation)\n })\n },\n\n innerHtml: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.innerHTML = safeScalar(html)\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n insertAdjacentHtml: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, position, focusSelector } = operation\n element.insertAdjacentHTML(position || 'beforeend', safeScalar(html))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n insertAdjacentText: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { text, position, focusSelector } = operation\n element.insertAdjacentText(position || 'beforeend', safeScalar(text))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n outerHtml: operation => {\n processElements(operation, element => {\n const parent = element.parentElement\n const idx = parent && Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.outerHTML = safeScalar(html)\n assignFocus(focusSelector)\n })\n after(parent ? parent.children[idx] : document.documentElement, operation)\n })\n },\n\n prepend: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.insertAdjacentHTML('afterbegin', safeScalar(html))\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n remove: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { focusSelector } = operation\n element.remove()\n assignFocus(focusSelector)\n })\n after(document, operation)\n })\n },\n\n replace: operation => {\n processElements(operation, element => {\n const parent = element.parentElement\n const idx = parent && Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { html, focusSelector } = operation\n element.outerHTML = safeScalar(html)\n assignFocus(focusSelector)\n })\n after(parent ? parent.children[idx] : document.documentElement, operation)\n })\n },\n\n textContent: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { text, focusSelector } = operation\n element.textContent = safeScalar(text)\n assignFocus(focusSelector)\n })\n after(element, operation)\n })\n },\n\n // Element Property Mutations\n\n addCssClass: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.classList.add(...getClassNames([safeStringOrArray(name)]))\n })\n after(element, operation)\n })\n },\n\n removeAttribute: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.removeAttribute(safeString(name))\n })\n after(element, operation)\n })\n },\n\n removeCssClass: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name } = operation\n element.classList.remove(...getClassNames([safeStringOrArray(name)]))\n if (element.classList.length === 0) element.removeAttribute('class')\n })\n after(element, operation)\n })\n },\n\n setAttribute: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.setAttribute(safeString(name), safeScalar(value))\n })\n after(element, operation)\n })\n },\n\n setDatasetProperty: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.dataset[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setProperty: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n if (name in element) element[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setStyle: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, value } = operation\n element.style[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setStyles: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { styles } = operation\n for (let [name, value] of Object.entries(styles))\n element.style[safeString(name)] = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n setValue: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { value } = operation\n element.value = safeScalar(value)\n })\n after(element, operation)\n })\n },\n\n // DOM Events and Meta-Operations\n\n dispatchEvent: operation => {\n processElements(operation, element => {\n before(element, operation)\n operate(operation, () => {\n const { name, detail } = operation\n dispatch(element, safeString(name), safeObject(detail))\n })\n after(element, operation)\n })\n },\n\n setMeta: operation => {\n before(document, operation)\n operate(operation, () => {\n const { name, content } = operation\n let meta = document.head.querySelector(`meta[name='${name}']`)\n if (!meta) {\n meta = document.createElement('meta')\n meta.name = safeString(name)\n document.head.appendChild(meta)\n }\n meta.content = safeScalar(content)\n })\n after(document, operation)\n },\n\n setTitle: operation => {\n before(document, operation)\n operate(operation, () => {\n const { title } = operation\n document.title = safeScalar(title)\n })\n after(document, operation)\n },\n\n // Browser Manipulations\n\n clearStorage: operation => {\n before(document, operation)\n operate(operation, () => {\n const { type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.clear()\n })\n after(document, operation)\n },\n\n go: operation => {\n before(window, operation)\n operate(operation, () => {\n const { delta } = operation\n history.go(delta)\n })\n after(window, operation)\n },\n\n pushState: operation => {\n before(window, operation)\n operate(operation, () => {\n const { state, title, url } = operation\n history.pushState(safeObject(state), safeString(title), safeString(url))\n })\n after(window, operation)\n },\n\n redirectTo: operation => {\n before(window, operation)\n operate(operation, () => {\n let { url, action, turbo } = operation\n action = action || 'advance'\n url = safeString(url)\n if (turbo === undefined) turbo = true\n\n if (turbo) {\n if (window.Turbo) window.Turbo.visit(url, { action })\n if (window.Turbolinks) window.Turbolinks.visit(url, { action })\n if (!window.Turbo && !window.Turbolinks) window.location.href = url\n } else {\n window.location.href = url\n }\n })\n after(window, operation)\n },\n\n reload: operation => {\n before(window, operation)\n operate(operation, () => {\n window.location.reload()\n })\n after(window, operation)\n },\n\n removeStorageItem: operation => {\n before(document, operation)\n operate(operation, () => {\n const { key, type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.removeItem(safeString(key))\n })\n after(document, operation)\n },\n\n replaceState: operation => {\n before(window, operation)\n operate(operation, () => {\n const { state, title, url } = operation\n history.replaceState(\n safeObject(state),\n safeString(title),\n safeString(url)\n )\n })\n after(window, operation)\n },\n\n scrollIntoView: operation => {\n const { element } = operation\n before(element, operation)\n operate(operation, () => {\n element.scrollIntoView(operation)\n })\n after(element, operation)\n },\n\n setCookie: operation => {\n before(document, operation)\n operate(operation, () => {\n const { cookie } = operation\n document.cookie = safeScalar(cookie)\n })\n after(document, operation)\n },\n\n setFocus: operation => {\n const { element } = operation\n before(element, operation)\n operate(operation, () => {\n assignFocus(element)\n })\n after(element, operation)\n },\n\n setStorageItem: operation => {\n before(document, operation)\n operate(operation, () => {\n const { key, value, type } = operation\n const storage = type === 'session' ? sessionStorage : localStorage\n storage.setItem(safeString(key), safeScalar(value))\n })\n after(document, operation)\n },\n\n // Notifications\n\n consoleLog: operation => {\n before(document, operation)\n operate(operation, () => {\n const { message, level } = operation\n level && ['warn', 'info', 'error'].includes(level)\n ? console[level](message)\n : console.log(message)\n })\n after(document, operation)\n },\n\n consoleTable: operation => {\n before(document, operation)\n operate(operation, () => {\n const { data, columns } = operation\n console.table(data, safeArray(columns))\n })\n after(document, operation)\n },\n\n notification: operation => {\n before(document, operation)\n operate(operation, () => {\n const { title, options } = operation\n Notification.requestPermission().then(result => {\n operation.permission = result\n if (result === 'granted')\n new Notification(safeString(title), safeObject(options))\n })\n })\n after(document, operation)\n },\n\n // Morph operations\n\n morph: operation => {\n processElements(operation, element => {\n const { html } = operation\n const template = document.createElement('template')\n template.innerHTML = String(safeScalar(html)).trim()\n operation.content = template.content\n const parent = element.parentElement\n const idx = parent && Array.from(parent.children).indexOf(element)\n before(element, operation)\n operate(operation, () => {\n const { childrenOnly, focusSelector } = operation\n morphdom(\n element,\n childrenOnly ? template.content : template.innerHTML,\n {\n childrenOnly: !!childrenOnly,\n onBeforeElUpdated: shouldMorph(operation),\n onElUpdated: didMorph(operation)\n }\n )\n assignFocus(focusSelector)\n })\n after(parent ? parent.children[idx] : document.documentElement, operation)\n })\n }\n}\n","import Operations from './operations'\n\nlet operations = Operations\n\nconst add = newOperations => {\n operations = { ...operations, ...newOperations }\n}\n\nconst addOperations = operations => {\n add(operations)\n}\n\nconst addOperation = (name, operation) => {\n const operations = {}\n operations[name] = operation\n\n add(operations)\n}\n\nexport { addOperation, addOperations }\n\nexport default {\n get all () {\n return operations\n }\n}\n","let missingElement = 'warn'\n\nexport default {\n get behavior () {\n return missingElement\n },\n set (value) {\n if (['warn', 'ignore', 'event', 'exception'].includes(value))\n missingElement = value\n else\n console.warn(\"Invalid 'onMissingElement' option. Defaulting to 'warn'.\")\n }\n}\n","import { xpathToElement, xpathToElementArray, dispatch } from './utils'\nimport ActiveElement from './active_element'\nimport OperationStore from './operation_store'\nimport MissingElement from './missing_element'\n\nconst perform = (\n operations,\n options = { onMissingElement: MissingElement.behavior }\n) => {\n const batches = {}\n operations.forEach(operation => {\n if (!!operation.batch)\n batches[operation.batch] = batches[operation.batch]\n ? ++batches[operation.batch]\n : 1\n })\n operations.forEach(operation => {\n const name = operation.operation\n try {\n if (operation.selector) {\n if (operation.xpath) {\n operation.element = operation.selectAll\n ? xpathToElementArray(operation.selector)\n : xpathToElement(operation.selector)\n } else {\n operation.element = operation.selectAll\n ? document.querySelectorAll(operation.selector)\n : document.querySelector(operation.selector)\n }\n } else {\n operation.element = document\n }\n if (operation.element || options.onMissingElement !== 'ignore') {\n ActiveElement.set(document.activeElement)\n const cableReadyOperation = OperationStore.all[name]\n\n if (cableReadyOperation) {\n cableReadyOperation(operation)\n if (!!operation.batch && --batches[operation.batch] === 0)\n dispatch(document, 'cable-ready:batch-complete', {\n batch: operation.batch\n })\n } else {\n console.error(\n `CableReady couldn't find the \"${name}\" operation. Make sure you use the camelized form when calling an operation method.`\n )\n }\n }\n } catch (e) {\n if (operation.element) {\n console.error(\n `CableReady detected an error in ${name || 'operation'}: ${\n e.message\n }. If you need to support older browsers make sure you've included the corresponding polyfills. https://docs.stimulusreflex.com/setup#polyfills-for-ie11.`\n )\n console.error(e)\n } else {\n const warning = `CableReady ${name ||\n ''} operation failed due to missing DOM element for selector: '${\n operation.selector\n }'`\n switch (options.onMissingElement) {\n case 'ignore':\n break\n case 'event':\n dispatch(document, 'cable-ready:missing-element', {\n warning,\n operation\n })\n break\n case 'exception':\n throw warning\n default:\n console.warn(warning)\n }\n }\n }\n })\n}\n\nconst performAsync = (\n operations,\n options = { onMissingElement: MissingElement.behavior }\n) => {\n return new Promise((resolve, reject) => {\n try {\n resolve(perform(operations, options))\n } catch (err) {\n reject(err)\n }\n })\n}\n\nexport { perform, performAsync }\n","export default class SubscribingElement extends HTMLElement {\n static get tagName () {\n throw new Error('Implement the tagName() getter in the inheriting class')\n }\n\n static define () {\n if (!customElements.get(this.tagName)) {\n customElements.define(this.tagName, this)\n }\n }\n\n disconnectedCallback () {\n if (this.channel) this.channel.unsubscribe()\n }\n\n createSubscription (consumer, channel, receivedCallback) {\n this.channel = consumer.subscriptions.create(\n {\n channel,\n identifier: this.identifier\n },\n {\n received: receivedCallback\n }\n )\n }\n\n get preview () {\n return (\n document.documentElement.hasAttribute('data-turbolinks-preview') ||\n document.documentElement.hasAttribute('data-turbo-preview')\n )\n }\n\n get identifier () {\n return this.getAttribute('identifier')\n }\n}\n","let consumer\n\nconst BACKOFF = [25, 50, 75, 100, 200, 250, 500, 800, 1000, 2000]\n\nconst wait = (ms) => new Promise(resolve => setTimeout(resolve, ms))\n\nconst getConsumerWithRetry = async (retry = 0) => {\n if (consumer) return consumer\n\n if (retry >= BACKOFF.length) {\n throw new Error(\"Couldn't obtain a Action Cable consumer within 5s\")\n }\n\n await wait(BACKOFF[retry])\n\n return await getConsumerWithRetry(retry + 1)\n}\n\nexport default {\n setConsumer (value) {\n consumer = value\n },\n\n get consumer () {\n return consumer\n },\n\n async getConsumer () {\n return await getConsumerWithRetry()\n }\n}\n","import { perform } from '../cable_ready'\nimport SubscribingElement from './subscribing_element'\nimport CableConsumer from '../cable_consumer'\nimport MissingElement from '../missing_element'\n\nexport default class StreamFromElement extends SubscribingElement {\n static get tagName () {\n return 'cable-ready-stream-from'\n }\n\n async connectedCallback () {\n if (this.preview) return\n\n const consumer = await CableConsumer.getConsumer()\n\n if (consumer) {\n this.createSubscription(\n consumer,\n 'CableReady::Stream',\n this.performOperations.bind(this)\n )\n } else {\n console.error(\n 'The `cable_ready_stream_from` helper cannot connect. You must initialize CableReady with an Action Cable consumer.'\n )\n }\n }\n\n performOperations (data) {\n if (data.cableReady)\n perform(data.operations, { onMissingElement: this.onMissingElement })\n }\n\n get onMissingElement () {\n const value = this.getAttribute('missing') || MissingElement.behavior\n\n // stream_from does not support raising exceptions on missing elements because there's no way to catch them\n if (['warn', 'ignore', 'event'].includes(value)) return value\n else {\n console.warn(\"Invalid 'missing' attribute. Defaulting to 'warn'.\")\n return 'warn'\n }\n }\n}\n","let debugging = false\n\nexport default {\n get enabled () {\n return debugging\n },\n get disabled () {\n return !debugging\n },\n get value () {\n return debugging\n },\n set (value) {\n debugging = !!value\n },\n set debug (value) {\n debugging = !!value\n }\n}\n","import Debug from '../debug'\n\nconst request = (data, blocks) => {\n if (Debug.disabled) return\n\n console.log(\n `\\u2191 Updatable request affecting ${blocks.length} element(s): `,\n {\n elements: blocks.map(b => b.element),\n identifiers: blocks.map(b => b.element.getAttribute('identifier')),\n data\n }\n )\n}\n\nconst cancel = (timestamp, reason) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(\n `\\u274C Updatable request canceled after ${duration}ms: ${reason}`\n )\n}\n\nconst response = (timestamp, element, urls) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(`\\u2193 Updatable response: All URLs fetched in ${duration}ms`, {\n element,\n urls\n })\n}\n\nconst morphStart = (timestamp, element) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(`\\u21BB Updatable morph: starting after ${duration}ms`, {\n element\n })\n}\n\nconst morphEnd = (timestamp, element) => {\n if (Debug.disabled) return\n\n const duration = new Date() - timestamp\n console.log(`\\u21BA Updatable morph: completed after ${duration}ms`, {\n element\n })\n}\n\nexport default { request, cancel, response, morphStart, morphEnd }\n","import morphdom from 'morphdom'\nimport SubscribingElement from './subscribing_element'\n\nimport { shouldMorph } from '../morph_callbacks'\nimport { debounce, assignFocus, dispatch, graciouslyFetch } from '../utils'\n\nimport ActiveElement from '../active_element'\nimport CableConsumer from '../cable_consumer'\nimport Log from '../updatable/log'\n\nconst template = `\n<style>\n :host {\n display: block;\n }\n</style>\n<slot></slot>\n`\n\nfunction url (element) {\n return element.hasAttribute('url')\n ? element.getAttribute('url')\n : location.href\n}\n\nexport default class UpdatesForElement extends SubscribingElement {\n static get tagName () {\n return 'cable-ready-updates-for'\n }\n\n constructor () {\n super()\n const shadowRoot = this.attachShadow({ mode: 'open' })\n shadowRoot.innerHTML = template\n }\n\n async connectedCallback () {\n if (this.preview) return\n this.update = debounce(this.update.bind(this), this.debounce)\n\n const consumer = await CableConsumer.getConsumer()\n\n if (consumer) {\n this.createSubscription(consumer, 'CableReady::Stream', this.update)\n } else {\n console.error(\n 'The `cable_ready_updates_for` helper cannot connect. You must initialize CableReady with an Action Cable consumer.'\n )\n }\n }\n\n async update (data) {\n this.lastUpdateTimestamp = new Date()\n\n const blocks = Array.from(\n document.querySelectorAll(this.query),\n element => new Block(element)\n ).filter(block => block.shouldUpdate(data))\n\n Log.request(data, blocks)\n\n if (blocks.length === 0) {\n Log.cancel(this.lastUpdateTimestamp, 'All elements filtered out')\n\n return\n }\n\n // first updates-for element in the DOM *at any given moment* updates all of the others\n if (blocks[0].element !== this) {\n Log.cancel(this.lastUpdateTimestamp, 'Update already requested')\n\n return\n }\n\n // hold a reference to the active element so that it can be restored after the morph\n ActiveElement.set(document.activeElement)\n\n // store all retrieved HTML in an object keyed by URL to minimize fetch calls\n this.html = {}\n\n const uniqueUrls = [...new Set(blocks.map(block => block.url))]\n\n await Promise.all(\n uniqueUrls.map(async url => {\n if (!this.html.hasOwnProperty(url)) {\n const response = await graciouslyFetch(url, {\n 'X-Cable-Ready': 'update'\n })\n this.html[url] = await response.text()\n }\n })\n )\n\n Log.response(this.lastUpdateTimestamp, this, uniqueUrls)\n\n // track current block index for each URL; referred to as fragments\n this.index = {}\n\n blocks.forEach(block => {\n // if the block's URL is not in the index, initialize it to 0; otherwise, increment it\n this.index.hasOwnProperty(block.url)\n ? this.index[block.url]++\n : (this.index[block.url] = 0)\n\n block.process(data, this.html, this.index, this.lastUpdateTimestamp)\n })\n }\n\n get query () {\n return `${this.tagName}[identifier=\"${this.identifier}\"]`\n }\n\n get identifier () {\n return this.getAttribute('identifier')\n }\n\n get debounce () {\n return this.hasAttribute('debounce')\n ? parseInt(this.getAttribute('debounce'))\n : 20\n }\n}\n\nclass Block {\n constructor (element) {\n this.element = element\n }\n\n async process (data, html, index, startTimestamp) {\n const blockIndex = index[this.url]\n const template = document.createElement('template')\n this.element.setAttribute('updating', 'updating')\n\n template.innerHTML = String(html[this.url]).trim()\n\n await this.resolveTurboFrames(template.content)\n\n const fragments = template.content.querySelectorAll(this.query)\n\n if (fragments.length <= blockIndex) {\n console.warn(\n `Update aborted due to insufficient number of elements. The offending url is ${this.url}.`\n )\n return\n }\n\n const operation = {\n element: this.element,\n html: fragments[blockIndex],\n permanentAttributeName: 'data-ignore-updates'\n }\n\n dispatch(this.element, 'cable-ready:before-update', operation)\n Log.morphStart(startTimestamp, this.element)\n\n morphdom(this.element, fragments[blockIndex], {\n childrenOnly: true,\n onBeforeElUpdated: shouldMorph(operation),\n onElUpdated: _ => {\n this.element.removeAttribute('updating')\n dispatch(this.element, 'cable-ready:after-update', operation)\n assignFocus(operation.focusSelector)\n }\n })\n Log.morphEnd(startTimestamp, this.element)\n }\n\n async resolveTurboFrames (documentFragment) {\n const reloadingTurboFrames = [\n ...documentFragment.querySelectorAll(\n 'turbo-frame[src]:not([loading=\"lazy\"])'\n )\n ]\n\n return Promise.all(\n reloadingTurboFrames.map(frame => {\n return new Promise(async resolve => {\n const frameResponse = await graciouslyFetch(\n frame.getAttribute('src'),\n {\n 'Turbo-Frame': frame.id,\n 'X-Cable-Ready': 'update'\n }\n )\n\n const frameTemplate = document.createElement('template')\n frameTemplate.innerHTML = await frameResponse.text()\n\n // recurse here to get all nested eager loaded frames\n await this.resolveTurboFrames(frameTemplate.content)\n\n const selector = `turbo-frame#${frame.id}`\n const frameContent = frameTemplate.content.querySelector(selector)\n const content = frameContent ? frameContent.innerHTML.trim() : ''\n\n docFragment.querySelector(selector).innerHTML = content\n\n resolve()\n })\n })\n )\n }\n\n shouldUpdate (data) {\n // if everything that could prevent an update is false, update this block\n return !this.ignoresInnerUpdates && this.hasChangesSelectedForUpdate(data)\n }\n\n hasChangesSelectedForUpdate (data) {\n // if there's an only attribute, only update if at least one of the attributes changed is in the allow list\n const only = this.element.getAttribute('only')\n\n return !(\n only &&\n data.changed &&\n !only.split(' ').some(attribute => data.changed.includes(attribute))\n )\n }\n\n get ignoresInnerUpdates () {\n // don't update during a Reflex or Turbolinks redraw\n return (\n this.element.hasAttribute('ignore-inner-updates') &&\n this.element.hasAttribute('performing-inner-update')\n )\n }\n\n get url () {\n return this.element.hasAttribute('url')\n ? this.element.getAttribute('url')\n : location.href\n }\n\n get identifier () {\n return this.element.identifier\n }\n\n get query () {\n return this.element.query\n }\n}\n","export const registerInnerUpdates = () => {\n document.addEventListener('stimulus-reflex:before', event => {\n recursiveMarkUpdatesForElements(event.detail.element)\n })\n\n document.addEventListener('stimulus-reflex:after', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.detail.element)\n })\n })\n\n document.addEventListener('turbo:submit-start', event => {\n recursiveMarkUpdatesForElements(event.target)\n })\n\n document.addEventListener('turbo:submit-end', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n\n document.addEventListener('turbo-boost:command:start', event => {\n recursiveMarkUpdatesForElements(event.target)\n })\n\n document.addEventListener('turbo-boost:command:finish', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n\n document.addEventListener('turbo-boost:command:error', event => {\n setTimeout(() => {\n recursiveUnmarkUpdatesForElements(event.target)\n })\n })\n}\n\nconst recursiveMarkUpdatesForElements = leaf => {\n const closestUpdatesFor =\n leaf &&\n leaf.parentElement &&\n leaf.parentElement.closest('cable-ready-updates-for')\n if (closestUpdatesFor) {\n closestUpdatesFor.setAttribute('performing-inner-update', '')\n recursiveMarkUpdatesForElements(closestUpdatesFor)\n }\n}\n\nconst recursiveUnmarkUpdatesForElements = leaf => {\n const closestUpdatesFor =\n leaf &&\n leaf.parentElement &&\n leaf.parentElement.closest('cable-ready-updates-for')\n if (closestUpdatesFor) {\n closestUpdatesFor.removeAttribute('performing-inner-update')\n recursiveUnmarkUpdatesForElements(closestUpdatesFor)\n }\n}\n","import StreamFromElement from './stream_from_element'\nimport UpdatesForElement from './updates_for_element'\n\nimport { registerInnerUpdates } from '../updatable/inner_updates_compat'\n\nexport const defineElements = () => {\n registerInnerUpdates()\n\n StreamFromElement.define()\n UpdatesForElement.define()\n}\n","import morphdom from 'morphdom'\n\nimport packageInfo from '../package.json'\nimport { perform, performAsync } from './cable_ready'\nimport { defineElements } from './elements'\nimport { shouldMorphCallbacks, didMorphCallbacks } from './morph_callbacks'\n\nimport * as MorphCallbacks from './morph_callbacks'\nimport * as Utils from './utils'\n\nimport OperationStore, { addOperation, addOperations } from './operation_store'\nimport StreamFromElement from './elements/stream_from_element'\nimport UpdatesForElement from './elements/updates_for_element'\nimport SubscribingElement from './elements/subscribing_element'\nimport CableConsumer from './cable_consumer'\nimport Debug from './debug'\n\nconst initialize = (initializeOptions = {}) => {\n const { consumer, onMissingElement, debug } = initializeOptions\n\n Debug.set(!!debug)\n\n if (consumer) {\n CableConsumer.setConsumer(consumer)\n } else {\n console.error(\n 'CableReady requires a reference to your Action Cable `consumer` for its helpers to function.\\nEnsure that you have imported the `CableReady` package as well as `consumer` from your `channels` folder, then call `CableReady.initialize({ consumer })`.'\n )\n }\n\n if (onMissingElement) {\n MissingElement.set(onMissingElement)\n }\n\n defineElements()\n}\n\nexport {\n Utils,\n MorphCallbacks,\n StreamFromElement,\n UpdatesForElement,\n SubscribingElement\n}\n\nconst global = {\n perform,\n performAsync,\n shouldMorphCallbacks,\n didMorphCallbacks,\n initialize,\n addOperation,\n addOperations,\n version: packageInfo.version,\n cable: CableConsumer,\n get DOMOperations () {\n console.warn(\n 'DEPRECATED: Please use `CableReady.operations` instead of `CableReady.DOMOperations`'\n )\n return OperationStore.all\n },\n get operations () {\n return OperationStore.all\n },\n get consumer () {\n return CableConsumer.consumer\n }\n}\n\nwindow.CableReady = global\n\nexport default global\n"],"names":["inputTags","INPUT","TEXTAREA","SELECT","mutableTags","OPTION","textInputTypes","color","date","datetime","email","month","number","password","range","search","tel","text","textarea","time","url","week","activeElement","ActiveElement","element","set","isTextInput","tagName","type","assignFocus","selector","focusElement","nodeType","Node","ELEMENT_NODE","document","querySelector","focus","dispatch","name","detail","event","CustomEvent","bubbles","cancelable","dispatchEvent","window","jQuery","trigger","xpathToElement","xpath","evaluate","XPathResult","FIRST_ORDERED_NODE_TYPE","singleNodeValue","xpathToElementArray","reverse","snapshotList","ORDERED_NODE_SNAPSHOT_TYPE","snapshots","i","snapshotLength","push","snapshotItem","getClassNames","names","Array","from","flat","processElements","operation","callback","selectAll","forEach","kebabize","result","word","index","toLowerCase","str","words","reduce","match","operate","cancel","delay","setTimeout","before","target","after","debounce","fn","timer","args","clearTimeout","apply","this","handleErrors","response","ok","Error","statusText","safeScalar","val","undefined","includes","console","warn","safeString","String","safeArray","arr","isArray","safeObject","obj","Object","safeStringOrArray","elem","async","graciouslyFetch","additionalHeaders","fetch","headers","e","error","fragment","XMLSerializer","serializeToString","shouldMorph","fromEl","toEl","shouldMorphCallbacks","map","didMorph","el","didMorphCallbacks","verifyNotMutable","isEqualNode","verifyNotContentEditable","isContentEditable","verifyNotPermanent","permanentAttributeName","permanent","closest","ignore","value","attributes","attribute","setAttribute","Operations","append","html","focusSelector","insertAdjacentHTML","graft","parent","parentElement","appendChild","innerHtml","innerHTML","insertAdjacentHtml","position","insertAdjacentText","outerHtml","idx","children","indexOf","outerHTML","documentElement","prepend","remove","replace","textContent","addCssClass","classList","add","removeAttribute","removeCssClass","length","setDatasetProperty","dataset","setProperty","setStyle","style","setStyles","styles","entries","setValue","setMeta","content","meta","head","createElement","setTitle","title","clearStorage","sessionStorage","localStorage","clear","go","delta","history","pushState","state","redirectTo","action","turbo","Turbo","visit","Turbolinks","location","href","reload","removeStorageItem","key","removeItem","replaceState","scrollIntoView","setCookie","cookie","setFocus","setStorageItem","setItem","consoleLog","message","level","log","consoleTable","data","columns","table","notification","options","Notification","requestPermission","then","permission","morph","template","trim","childrenOnly","morphdom","onBeforeElUpdated","onElUpdated","operations","newOperations","OperationStore","all","missingElement","MissingElement$1","behavior","perform","onMissingElement","MissingElement","batches","batch","querySelectorAll","cableReadyOperation","warning","SubscribingElement","HTMLElement","static","customElements","get","define","disconnectedCallback","channel","unsubscribe","createSubscription","consumer","receivedCallback","subscriptions","create","identifier","received","preview","hasAttribute","getAttribute","BACKOFF","getConsumerWithRetry","retry","ms","Promise","resolve","CableConsumer","setConsumer","StreamFromElement","getConsumer","performOperations","bind","cableReady","debugging","Debug","enabled","disabled","debug","Log","blocks","elements","b","identifiers","timestamp","reason","duration","Date","urls","UpdatesForElement","constructor","super","attachShadow","mode","update","lastUpdateTimestamp","query","Block","filter","block","shouldUpdate","uniqueUrls","Set","hasOwnProperty","process","parseInt","startTimestamp","blockIndex","resolveTurboFrames","fragments","_","documentFragment","reloadingTurboFrames","frame","frameResponse","id","frameTemplate","frameContent","docFragment","ignoresInnerUpdates","hasChangesSelectedForUpdate","only","changed","split","some","recursiveMarkUpdatesForElements","leaf","closestUpdatesFor","recursiveUnmarkUpdatesForElements","defineElements","addEventListener","global","performAsync","reject","err","initialize","initializeOptions","addOperation","addOperations","version","packageInfo","cable","DOMOperations","CableReady"],"mappings":"4CAAO,MAAMA,EAAY,CACvBC,OAAO,EACPC,UAAU,EACVC,QAAQ,GAGGC,EAAc,CACzBH,OAAO,EACPC,UAAU,EACVG,QAAQ,GAGGC,EAAiB,CAC5B,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACdC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,OAAO,EACPC,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,OAAO,EACPC,QAAQ,EACRC,KAAK,EACLC,MAAM,EACNC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,MAAM,GC9BR,IAAIC,EAEJ,IAAeC,EAAA,CACTC,cACF,OAAOF,CACR,EACDG,IAAKD,GACHF,EAAgBE,CACjB,GCHH,MAAME,EAAcF,GACXxB,EAAUwB,EAAQG,UAAYrB,EAAekB,EAAQI,MAOxDC,EAAcC,IAClB,MAIMC,GAHJD,GAAYA,EAASE,WAAaC,KAAKC,aACnCJ,EACAK,SAASC,cAAcN,KACGP,EAAcC,QAC1CO,GAAgBA,EAAaM,OAAON,EAAaM,OAAO,EASxDC,EAAW,CAACd,EAASe,EAAMC,EAAS,CAAA,KACxC,MACMC,EAAQ,IAA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