"use strict";(self.webpackChunkotter_blocks=self.webpackChunkotter_blocks||[]).push([[878],{3732:function(e,t,n){var s=n(7143),o=n(4715),i=n(3656),a=n(8490),r=n.n(a);const c=["themeisle-blocks","atomic-wind"],l=()=>(0,s.select)("core/blocks").getBlockTypes().filter((e=>c.includes(e.category))).map((e=>e.name)),u=()=>{if(!(0,s.select)(o.store))return 0;const{getGlobalBlockCount:e}=(0,s.select)(o.store);return l().reduce(((t,n)=>t+e(n)),0)};let f=null,d=null;const g=()=>{if(null!==d||!f)return;const{__unstableIsEditorReady:e}=(0,s.select)("core/editor");e?.()&&(d=u())},m=()=>{f&&null!==d&&!f.firstInsertDone&&u()>d&&(f.firstInsertDone=!0,window.oTrk?.set("activation-first-insert",{feature:"activation",featureComponent:"first-insert",featureValue:"true"}))};var b=n(6087);const h=new Set,w=(e,t,n)=>(e.forEach((e=>{if(!1===e.isValid&&t.includes(e.name)&&n.add(e.name),"core/missing"===e.name){const s=e.attributes?.originalName;s&&t.includes(s)&&n.add(s)}e.innerBlocks?.length&&w(e.innerBlocks,t,n)})),n),k=()=>{const e=l();if(0===e.length)return;const{getBlocks:t}=(0,s.select)(o.store);w(t(),e,new Set).forEach((e=>{h.has(e)||(h.add(e),window.oTrk?.set(`block-health-${e}`,{feature:"block-health",featureComponent:"render-error",featureValue:e}))}))};let p={},v=!1;const B=()=>{const e=l();if(0===e.length)return;const t=(()=>{const{getGlobalBlockCount:e}=(0,s.select)(o.store),t={};return l().forEach((n=>{t[n]=e(n)})),t})();v?e.forEach((e=>{const n=(t[e]||0)-(p[e]||0);0!==n&&window.oTrk?.set(`${e}:${Date.now()}`,{feature:"block-usage",featureComponent:e,featureValue:String(n)})})):v=!0,p=t};let E=!1,D=!1,_=[],S=[];const y=e=>-1<_.indexOf(e.name),C=e=>{if(e.innerBlocks){const t=e.innerBlocks.filter(y);S.push(...t),t.forEach(C)}},G=(0,b.debounce)((async()=>{const{getEditorBlocks:e}=(0,s.select)("core/editor");let t=e();t=t.filter(y);const n=e=>{if(e.innerBlocks){const s=e.innerBlocks.filter(y);t.push(...s),s.forEach(n)}},o={...window.themeisleGutenberg.dataLogging};if(0<t.length&&o.blocks){t.forEach(n),t=t.map((e=>e.name));const e=[];t.forEach((t=>{const n=e.find((e=>e.name===t));n?n.instances=n.instances+1:e.push({name:t,instances:1})}));const s=[...e],i=[...S];s.map((e=>{const t=i.find((t=>t.name===e.name));return t&&e.instances>=t.instances?(e.instances=e.instances-t.instances,e):e})),0===o.blocks.length?o.blocks=[...s]:(o.blocks.map((e=>{const t=s.find((t=>t.name===e.name)),n=s.findIndex((t=>t.name===e.name));return t?(e.instances=e.instances+t.instances,s.splice(n,1),e):e})),0<s.length&&(o.blocks=[...o.blocks,...s]))}const i=new window.wp.api.models.Settings({otter_blocks_logger_data:o});await i.save()}),1e3);window.themeisleGutenberg.dataLogging=window.themeisleGutenberg.dataLogging||{};const P=()=>{const e=(()=>{const e=window.themeisleGutenberg?.telemetry||{};return{loggerData:e.loggerData||null,firstSaveDone:Boolean(e.firstSaveDone),firstInsertDone:!1}})();(e=>{e.loggerData&&(window.themeisleGutenberg.dataLogging=e.loggerData)})(e),f=e,d=null,g(),(0,s.subscribe)((()=>{(()=>{const{getBlockTypes:e}=(0,s.select)("core/blocks"),{__unstableIsEditorReady:t,getEditorBlocks:n,isAutosavingPost:o,isCurrentPostPublished:i,isEditedPostNew:a,isPublishingPost:r,isSavingPost:c}=(0,s.select)("core/editor"),l=o(),u=r(),f=c(),d=i(),g=e();if(_=g.filter((e=>"themeisle-blocks"===e.category)).map((e=>e.name)),(u||d&&f)&&!l&&(D=!0,G()),!E&&t()&&!a()&&!D){E=t(),S=n(),S=S.filter(y),S.forEach(C),S=S.map((e=>e.name));const e=[];S.forEach((t=>{const n=e.find((e=>e.name===t));n?n.instances=n.instances+1:e.push({name:t,instances:1})})),S=e}})(),(()=>{if(!f)return;const{isAutosavingPost:e,isSavingPost:t}=(0,s.select)("core/editor");if(g(),t()&&!e()&&!f.firstSaveDone){const e=u();0<e&&(async e=>{var t;f.firstSaveDone=!0,window.oTrk?.set("activation-first-save",{feature:"activation",featureComponent:"first-save",featureValue:"true"}),window.oTrk?.set("activation-first-save-depth",{feature:"activation",featureComponent:"first-save-depth",featureValue:(t=e,1>=t?"1":3>=t?"2-3":10>=t?"4-10":"10+")}),await(async e=>{const t=new window.wp.api.models.Settings({[e]:!0});await t.save().catch((()=>{}))})("otter_activation_first_save")})(e)}})()}),i.store),(0,s.subscribe)(m,o.store)};r()((()=>{(0,s.select)(o.store)&&(0,s.select)("core/blocks")&&setTimeout((()=>{(0,s.subscribe)((0,b.debounce)(k,1e3),o.store)}),1e3),Boolean(window.themeisleGutenberg?.isBlockEditor)&&(0,s.select)("core/editor")&&(P(),Boolean(window.themeisleGutenberg?.isBlockEditor)&&setTimeout((()=>{const e=(0,b.debounce)(B,1e3);(0,s.subscribe)(e,o.store),B()}),1e3))}))}}]);