{
  "version": 3,
  "sources": ["../../src/slot-fill/provider.tsx"],
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { observableMap } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport { isShallowEqual } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport SlotFillContext from './context';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nfunction createSlotRegistry() {\n  const slots = observableMap();\n  const fills = observableMap();\n  function registerSlot(name, slot) {\n    slots.set(name, slot);\n  }\n  function unregisterSlot(name, instance) {\n    // If a previous instance of a Slot by this name unmounts, do nothing,\n    // as the slot and its fills should only be removed for the current\n    // known instance.\n    const currentSlot = slots.get(name);\n    if (!currentSlot || currentSlot.instance !== instance) {\n      return;\n    }\n    slots.delete(name);\n  }\n  function updateSlot(name, slot) {\n    if (slot.type !== 'portal') {\n      return;\n    }\n    const slotForName = slots.get(name);\n    if (!slotForName) {\n      return;\n    }\n    if (slotForName.type !== 'portal') {\n      return;\n    }\n    if (slotForName.instance !== slot.instance) {\n      return;\n    }\n    if (isShallowEqual(slotForName.fillProps, slot.fillProps)) {\n      return;\n    }\n    slots.set(name, slot);\n  }\n  function registerFill(name, fill) {\n    fills.set(name, [...(fills.get(name) || []), fill]);\n  }\n  function unregisterFill(name, instance) {\n    const fillsForName = fills.get(name);\n    if (!fillsForName) {\n      return;\n    }\n    fills.set(name, fillsForName.filter(fill => fill.instance !== instance));\n  }\n  function updateFill(name, fill) {\n    const fillsForName = fills.get(name);\n    if (!fillsForName) {\n      return;\n    }\n    const fillForInstance = fillsForName.find(f => f.instance === fill.instance);\n    if (!fillForInstance) {\n      return;\n    }\n    if (fillForInstance.children === fill.children) {\n      return;\n    }\n    fills.set(name, fillsForName.map(f => {\n      if (f.instance === fill.instance) {\n        // Replace with the new fill record with updated `children`.\n        return fill;\n      }\n      return f;\n    }));\n  }\n  return {\n    slots,\n    fills,\n    registerSlot,\n    unregisterSlot,\n    updateSlot,\n    registerFill,\n    unregisterFill,\n    updateFill\n  };\n}\nexport function SlotFillProvider({\n  children\n}) {\n  const [contextValue] = useState(createSlotRegistry);\n  return /*#__PURE__*/_jsx(SlotFillContext.Provider, {\n    value: contextValue,\n    children: children\n  });\n}\nexport default SlotFillProvider;"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA8B;AAC9B,qBAAyB;AACzB,8BAA+B;AAK/B,qBAA4B;AAC5B,yBAA4B;AAC5B,SAAS,qBAAqB;AAC5B,QAAM,YAAQ,8BAAc;AAC5B,QAAM,YAAQ,8BAAc;AAC5B,WAAS,aAAa,MAAM,MAAM;AAChC,UAAM,IAAI,MAAM,IAAI;AAAA,EACtB;AACA,WAAS,eAAe,MAAM,UAAU;AAItC,UAAM,cAAc,MAAM,IAAI,IAAI;AAClC,QAAI,CAAC,eAAe,YAAY,aAAa,UAAU;AACrD;AAAA,IACF;AACA,UAAM,OAAO,IAAI;AAAA,EACnB;AACA,WAAS,WAAW,MAAM,MAAM;AAC9B,QAAI,KAAK,SAAS,UAAU;AAC1B;AAAA,IACF;AACA,UAAM,cAAc,MAAM,IAAI,IAAI;AAClC,QAAI,CAAC,aAAa;AAChB;AAAA,IACF;AACA,QAAI,YAAY,SAAS,UAAU;AACjC;AAAA,IACF;AACA,QAAI,YAAY,aAAa,KAAK,UAAU;AAC1C;AAAA,IACF;AACA,YAAI,wCAAe,YAAY,WAAW,KAAK,SAAS,GAAG;AACzD;AAAA,IACF;AACA,UAAM,IAAI,MAAM,IAAI;AAAA,EACtB;AACA,WAAS,aAAa,MAAM,MAAM;AAChC,UAAM,IAAI,MAAM,CAAC,GAAI,MAAM,IAAI,IAAI,KAAK,CAAC,GAAI,IAAI,CAAC;AAAA,EACpD;AACA,WAAS,eAAe,MAAM,UAAU;AACtC,UAAM,eAAe,MAAM,IAAI,IAAI;AACnC,QAAI,CAAC,cAAc;AACjB;AAAA,IACF;AACA,UAAM,IAA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