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,GACvB,IAAIX,EAAa,CAACW,EAAeN,IAIjC,OAHCL,EAAW,GAAGsB,UAAY,IAAIV,SAAQ,SAASW,GAC5CvB,EAAaA,EAAWoF,OAAOrE,EAAcQ,EAAOZ,GACxD,IACOX,CACX,CAzIAF,OAAOuF,WAAajB,IACZA,EAASkB,OAASlB,EAASkB,MAAMC,UACjCzF,OAAO4D,SAAS8B,QACpB,EA+IJlD,SAASmD,iBAAiB,qBAAsBC,IAC5CC,MAAMC,KAAKtD,SAASuD,iBAAiB,YAAcH,EAAMI,YAAc,sBAC9DlF,SAAQ,SAASC,GACtBkB,KAAOlB,EAAUkF,WAAe,GAAE7E,MAAM8E,MAAM,KAAKC,OAAO,GAAGC,KAAK,KAClE,IAAIC,EAAa,IAAIC,MAAM,cAAgBrE,MAC3CoE,EAAWL,YAAcJ,EAAMI,YAC/BK,EAAWlE,QAAUyD,EAAMzD,QAC3B,IAAI,IAAIoE,EAAQ,EAAGA,EAAQxF,EAAUkF,WAAWvF,OAAQ6F,IAAS,CAC7D,IAAIC,EAAOzF,EAAUkF,WAAWM,GAC5BC,EAAKvE,KAAKwE,WAAW,gBACrBJ,EAAWG,EAAKvE,MAAQuE,EAAKpF,MAErC,CACAoB,SAASkE,cAAcL,EAC3B,GAAE,IAGFrG,OAAOyE,OACPzE,OAAOyE,OAAOX,KAAKlC,GAAY8C,MAAK,SAASpD,GACzCA,EAAEqF,MAAM,aAAajC,MAAK,SAAS/C,GAC3BA,EACAA,EAAUiF,OAAOlC,MAAK,SAAS5C,GAC3B7B,mBAAmB0B,UAAYG,GAAQ,CAAC,EACxCd,EAAiBd,WACrB,IAEAc,EAAiBd,WAEzB,GACJ,IAEAc,EAAiBd,W","sources":["webpack://singletrack-portal/./app/assets/packs/components.js"],"sourcesContent":["window.__componentAdapter = {\n components: {},\n runner: null,\n componentsWaiting: 0,\n latestBatch: [],\n render: rerenderComponent,\n setExtraParam: setExtraParam,\n ajaxErrors: [],\n fragments: {}\n}\n\nconst COMPONENTS = 'components-v1'; // match this with service_worker.js and offline_handler.js\n\nwindow.onpopstate = response => {\n if (response.state && response.state.st_async) {\n window.location.reload();\n }\n};\n\nfunction __enqueueComponent(component, body, rerender, callback, subcomponents='[]') {\n __componentAdapter.components[component.id] = {\n id: component.id,\n name: component.name,\n children: component.children,\n body: body,\n jsc: !rerender && component.jsc,\n options: component.options,\n rerender: rerender,\n extra_params: component.extra_params,\n subcomponents: JSON.parse('[' + subcomponents + ']')\n };\n\n if (__componentAdapter.runner) {\n __componentAdapter.runner.execute();\n }\n if (callback) callback();\n}\n\nfunction renderComponents(components, rerender=false, callback=null) {\n var csrfTokenElement = document.querySelector('meta[name=\"csrf-token\"]');\n __initializeComponentAdapter(components);\n components.forEach(function(component) {\n if (component.deferred || !component.controller) {\n __componentAdapter.componentsWaiting -= 1;\n return component.deferred = false;\n }\n\n let related_fragment = __componentAdapter.fragments[component.hash];\n if (related_fragment && !component.extra_params && related_fragment[3] === true) {\n return __enqueueFragment(related_fragment, component, callback);\n }\n var xhr = __createXhr(component, csrfTokenElement);\n xhr.onload = function() {\n if (xhr.status !== 200) {\n __componentAdapter.componentsWaiting -= 1;\n return __componentAdapter.ajaxErrors.push([xhr.responseText, component]);\n }\n __cacheResponse(component, xhr.responseText);\n let subcomponents = xhr.getResponseHeader('Subcomponent-Javascript');\n __enqueueComponent(component, xhr.responseText, rerender, callback, subcomponents);\n };\n xhr.onerror = function() {\n if (related_fragment && related_fragment[3] == 'prefer_online') {\n return __enqueueFragment(related_fragment, component, callback);\n }\n }\n xhr.send(component.options || {});\n });\n}\n\nfunction __initializeComponentAdapter(components) {\n __componentAdapter.latestBatch = components.map(function(c) { return c.id })\n __componentAdapter.componentsWaiting += components.length;\n __componentAdapter.ajaxErrors = [];\n if (__componentAdapter.runner) {\n __componentAdapter.runner.getLocator().loaded = false;\n }\n}\n\nfunction __cacheResponse(component, response) {\n if (!component.idempotent || component.hash in __componentAdapter.fragments) {\n return\n }\n __componentAdapter.fragments[component.hash] = [\n component.children,\n response,\n component.child_names,\n component.idempotent\n ];\n if (window.caches) {\n window.caches.open(COMPONENTS).then(function(c) {\n c.put('fragments', new Response(JSON.stringify(__componentAdapter.fragments)))\n });\n }\n}\n\nfunction __createXhr(component, csrfTokenElement) {\n var xhr = new XMLHttpRequest();\n var componentRequestQueryString = buildComponentQueryString(\n component.extra_params || {}, document.location.search)\n xhr.open('POST', '/' + component.controller + '_component/' + componentRequestQueryString);\n xhr.setRequestHeader('Content-Type', 'text/plain');\n xhr.setRequestHeader('Component-Id', component.id);\n xhr.setRequestHeader('Component-Hash', component.hash);\n if (csrfTokenElement) {\n xhr.setRequestHeader('X-CSRF-Token', csrfTokenElement.content);\n }\n return xhr;\n}\n\nfunction __enqueueFragment(related_fragment, component, callback) {\n let fragment = related_fragment[1].slice(0); // clone\n for (let i = 0; i < component.children.length; i++) {\n fragment = fragment\n .replace(\n 'wrapper_' + related_fragment[0][i] + ' ',\n 'wrapper_' + component.children[i] + ' '\n ).replace(\n 'data-component-id=' + related_fragment[0][i] + '>',\n 'data-component-id=' + component.children[i] + '>'\n );\n }\n __enqueueComponent(component, fragment, false, callback);\n}\n\nfunction rerenderComponent(id, asRerender=true, callback=null) {\n let componentsById = {}\n components.forEach(function(component) {\n componentsById[component.id] = component;\n });\n\n let componentsToRerender = __getChildren(id, componentsById);\n renderComponents(componentsToRerender, asRerender, callback);\n}\n\nfunction setExtraParam(id, key, value) {\n let component = components.find(c => c.id == id);\n component.extra_params = component.extra_params || {};\n component.extra_params[key] = value;\n if (component.children) {\n component.children.forEach(child => setExtraParam(child, key, value));\n }\n}\n\nfunction __getChildren(id, componentsById) {\n let components = [componentsById[id]];\n (components[0].children || []).forEach(function(child) {\n components = components.concat(__getChildren(child, componentsById));\n });\n return components;\n}\n\nfunction buildComponentQueryString(params, queryString = '') {\n Object.keys(params).forEach( (key) => {\n queryString += (queryString.includes('?')) ? `&${key}=${params[key]}` : `?${key}=${params[key]}`\n })\n return queryString;\n}\n\ndocument.addEventListener('ComponentRendered', (event) => {\n Array.from(document.querySelectorAll('#wrapper_' + event.componentId + ' .react-container'))\n .forEach(function(component) {\n name = component.attributes['id'].value.split('_').splice(1).join('_');\n let reactReady = new Event('ReactReady_' + name);\n reactReady.componentId = event.componentId;\n reactReady.options = event.options;\n for(let index = 0; index < component.attributes.length; index++ ){\n let node = component.attributes[index]\n if (node.name.startsWith('data-param')) {\n reactReady[node.name] = node.value\n }\n }\n document.dispatchEvent(reactReady);\n });\n})\n\nif (window.caches) { // Cache fragment hash.\n window.caches.open(COMPONENTS).then(function(c) {\n c.match('fragments').then(function(fragments) {\n if (fragments) {\n fragments.json().then(function(body) {\n __componentAdapter.fragments = body || {};\n renderComponents(components);\n });\n } else {\n renderComponents(components);\n }\n });\n });\n} else {\n renderComponents(components);\n}\n"],"names":["window","__componentAdapter","components","runner","componentsWaiting","latestBatch","render","id","asRerender","arguments","length","undefined","callback","componentsById","forEach","component","renderComponents","__getChildren","setExtraParam","key","value","find","c","extra_params","children","child","ajaxErrors","fragments","COMPONENTS","__enqueueComponent","body","rerender","subcomponents","name","jsc","options","JSON","parse","execute","csrfTokenElement","document","querySelector","map","getLocator","loaded","__initializeComponentAdapter","deferred","controller","related_fragment","hash","__enqueueFragment","xhr","XMLHttpRequest","componentRequestQueryString","params","queryString","Object","keys","includes","buildComponentQueryString","location","search","open","setRequestHeader","content","__createXhr","onload","status","push","responseText","response","idempotent","child_names","caches","then","put","Response","stringify","__cacheResponse","getResponseHeader","onerror","send","fragment","slice","i","replace","concat","onpopstate","state","st_async","reload","addEventListener","event","Array","from","querySelectorAll","componentId","attributes","split","splice","join","reactReady","Event","index","node","startsWith","dispatchEvent","match","json"],"sourceRoot":""}