self.BindingsTestRunner=self.BindingsTestRunner||{},Persistence.PersistenceBinding.prototype.toString=function(){return["{","       network: "+this.network.url(),"    fileSystem: "+this.fileSystem.url(),"}"].join("\n")},Persistence.AutomappingStatus.prototype.toString=function(){return["{","       network: "+this.network.url(),"    fileSystem: "+this.fileSystem.url(),"    exactMatch: "+this.exactMatch,"}"].join("\n")},BindingsTestRunner.waitForBinding=function(e){const n=self.Workspace.workspace.uiSourceCodes();for(const i of n){const n=self.Persistence.persistence.binding(i);if(n&&i.name()===e)return Promise.resolve(n)}return TestRunner.waitForEvent(Persistence.Persistence.Events.BindingCreated,self.Persistence.persistence,(n=>n.network.name()===e||n.fileSystem.name()===e))},BindingsTestRunner.addFooJSFile=function(e){return e.root.mkdir("devtools").mkdir("persistence").mkdir("resources").addFile("foo.js","\n\nwindow.foo = ()=>'foo';\n")},BindingsTestRunner.initializeTestMapping=function(){return new TestMapping(self.Persistence.persistence)};class TestMapping{constructor(e){this._persistence=e,e.addNetworkInterceptor((()=>!0)),this._bindings=new Set}async addBinding(e){if(this._findBinding(e))return TestRunner.addResult(`FAILED TO ADD BINDING: binding already exists for ${e}`),void TestRunner.completeTest();const n=await TestRunner.waitForUISourceCode(e,Workspace.projectTypes.Network),i=await TestRunner.waitForUISourceCode(e,Workspace.projectTypes.FileSystem),t=new Persistence.PersistenceBinding(n,i);this._bindings.add(t),await this._persistence.addBindingForTest(t)}_findBinding(e){for(const n of this._bindings)if(n.network.url().endsWith(e))return n;return null}async removeBinding(e){const n=this._findBinding(e);if(!n)return TestRunner.addResult(`FAILED TO REMOVE BINDING: binding does not exist for ${e}`),void TestRunner.completeTest();this._bindings.delete(n),await this._persistence.removeBindingForTest(n)}async dispose(){for(const e of this._bindings)await this._persistence.removeBindingForTest(e);this._bindings.clear()}}